Streamline your Unity UI development with ViewManagerPro, a lightweight and powerful solution for creating dynamic content and list views effortlessly. Designed to eliminate the complexities of traditional UI workflows, ViewManagerPro empowers developers to build visually appealing interfaces with minimal setup. With support for ContentView, ListView, and RecycleListView, you can focus on your data and views without worrying about hierarchy setup, component management, or manual instantiation. ContentView: Quickly display single objects or fetch and render content from APIs. Perfect for detailed views or object-centric UIs. ListView: Ideal for moderate datasets, automatically instantiating UI elements for each data entry. RecycleListView: Optimized for large datasets, rendering only visible objects in the viewport for exceptional performance. Built on top of an enhanced Recyclable Scroll Rect(https://github.com/MdIqubal/Recyclable-Scroll-Rect), ViewManagerPro addresses common issues and introduces additional features to meet the demands of modern Unity projects. Why Choose ViewManagerPro? No Setup Hassles: No need for manual hierarchy adjustments, ScrollRect additions, or layout configurations. Effortless API Integration: Fetch and display data seamlessly with integrated API support. Customizable And Flexible: Define your own models and view items with ease. Optimized for Performance: Lightweight and efficient, ensuring smooth performance even for large datasets. Whether you're building a simple content viewer or a complex data-driven interface, ViewManagerPro is your go-to solution for intuitive, efficient, and high-performance UI development. Tags: Unity, UI, ListView, RecycleListView, ContentView, API Integration, Lightweight, Game Development, ViewManagerPro.
$ dotnet add package MVC.ViewManagerProViewManagerPro is a lightweight and efficient Unity module that simplifies the creation of dynamic content views, lists, and optimized recycle views. With built-in support for API integration and data-driven UI instantiation, ViewManagerPro eliminates the need for manual setup and accelerates your development workflow.
ContentView
Display a single data object or fetch and render content directly from an API endpoint.
ListView
Easily create lists for moderate-sized datasets. Automatically instantiates UI elements for each data entry.
RecycleListView
Optimized for large datasets, rendering only the visible items in the viewport to ensure smooth performance.
No Manual Setup
Forget about adding ScrollRects, layouts, or content size fitters manually. ViewManagerPro handles everything for you.
API Integration
Seamlessly fetch and display data from APIs like https://jsonplaceholder.typicode.com/posts.
using MVC.ViewManagerPro;
First, create your model class that represents the data you want to display in your UI. For example, here's a model for a post:
public class PostData
{
public int userId;
public int id;
public string title;
public string body;
}
Next, create a view class that inherits from ViewItem and defines how each item in your view will be initialized. This is where you specify how to map your model data to UI elements like components. Here's an example of a view for displaying :
TextMeshProUGUIPostDatausing TMPro; // For TextMeshProUGUI
public class TestViewItem : ViewItem
{
public TextMeshProUGUI id;
public TextMeshProUGUI title;
public TextMeshProUGUI body;
internal PostData post;
public override void Initialize<T>(T postData)
{
post = postData as PostData;
id.text = post.id.ToString();
title.text = post.title;
body.text = post.body;
}
}To display a single object fetched from an API, use ContentView. Here's an example of calling ContentView with a PostData model:
_ = new ContentView<PostData>()
.Initialize(new APIConfig("https://jsonplaceholder.typicode.com/posts/1"), viewItem, parent)
.Show();In this example, ContentView fetches the data from https://jsonplaceholder.typicode.com/posts/1, passes it to the TestViewItem, and displays it in the UI.
To display a list of items, use ListView. This works for moderate datasets, automatically instantiating UI elements for each data entry:
_ = new ListView<PostData>()
.Initialize(new APIConfig("https://jsonplaceholder.typicode.com/posts"), viewItem, parent, scrollViewConfig)
.Show();Here, ListView fetches data from https://jsonplaceholder.typicode.com/posts and displays each post in a list.
For large datasets, use RecycleListView to optimize performance by rendering only visible items in the viewport:
_ = new RecycleListView<PostData>()
.Initialize(new APIConfig("https://jsonplaceholder.typicode.com/posts"), viewItem, parent, scrollViewConfig)
.Show();public class ScrollViewConfig
{
public DirectionType Direction;
public bool isGrid = false;
public int column = 1;
public int row = 1;
public Sprite backgroundImage;
public Color backgroundColor = new Color(1, 1, 1, 1f);
public MovementType movementType = MovementType.Elastic;
public float scrollSensitivity = 1;
public Vector2 spacing;
}