A modular UI management system for Unity that enables seamless screen transitions, event-driven UI control, and customizable screen behavior.If you have any questions about the package or its capabilities, please feel free to contact me: https://www.loags.de/contact/This Unity UI System package offers a comprehensive and flexible solution for managing complex user interfaces. It is designed with an event-driven architecture, allowing for highly modular and decoupled components that can communicate efficiently without hard dependencies. Whether you're building a game with nested menus, HUDs, pop-up notifications, or application interfaces with multiple screens, this system can handle it with ease.The system provides the ability to create and manage draggable screens, customizable screen configurations using ScriptableObject assets, and supports complex transitions between screens. With its screen hierarchy feature, it allows you to define parent-child relationships between screens, ensuring that UI screens can be nested, stacked, and managed according to your needs.A core feature of the package is its history tracking, which stores the stack of opened screens. This enables smooth navigation between screens, including back navigation, making it ideal for multi-step menus or workflows in games and applications. Furthermore, the package includes built-in support for in-game UIs and main menu UIs, complete with configurable screen transition behavior.In addition, the package is designed with performance in mind. It's optimized for mobile and desktop platforms, ensuring that it runs smoothly regardless of the device. The modularity of the package ensures that developers can extend, override, or replace any part of the system to fit their project needs.Full README:UI System for Unity created by: LoagsOverviewThis project is a flexible and extensible UI management system for Unity, designed to handle complex user interface (UI) interactions such as screen transitions, hierarchy management, and screen event handling. The system is built with scalability and modularity in mind, enabling you to manage multiple screens and their relationships with ease, while offering robust customization through ScriptableObject configurations.Features- Event-driven Architecture: Uses an event bus (UISystemEventBus) to decouple interactions between UI components, ensuring loose coupling and scalability.- Screen Transitions: Manages transitions between screens with support for additive and exclusive screen opening.- Screen Hierarchy Management: Handles the relationships between screens (parent-child screens) through UIScreenNode structures.- Screen History: Tracks the history of opened screens, enabling easy back navigation and the ability to restore previous states.- Draggable UI Components: Supports draggable UI screens and components that can be moved around within a defined area.- Customizable Screen Configurations: Screens can be customized using UIScreenConfig assets, enabling easy configuration in the Unity Editor.- Pause Menu & In-Game UI Support: Special managers for handling pause menus and in-game UI elements, in addition to the main menu.Structure of the SystemThe system is divided into several key components:UISystemManager: The core class that manages the entire UI system. It handles event subscriptions, screen hierarchy management, transitions, and screen history tracking.UIScreenConfig: A ScriptableObject asset that holds the configuration for each screen. This includes settings such as whether the screen is closable and whether it is the initial screen displayed when the system starts.UIScreenNode: Represents a node in the UI screen hierarchy. Each node contains information about the screen, its parent and child relationships, and whether the screen is active.UIScreenNodeManager: Manages the hierarchy of UI screens by creating nodes for each screen, and handling operations like finding, adding, or removing screens from the hierarchy.UIScreenRegistrar: Responsible for registering screens with the system and ensuring that screens are placed in the correct spot in the hierarchy (either as root screens or children of other screens).UIScreenTransitionManager: Handles screen transitions, such as opening and closing screens with animations or effects. Supports opening screens additively (without closing other screens) or exclusively (closing all other screens).UIScreenHistoryEntry: Tracks entries in the screen history stack. This allows for back navigation and restoring previous screens when needed.DraggableUIComponent: A component that allows a UI element to be draggable within a defined area. It implements Unity’s IDragHandler to handle drag events and manages resetting the position of draggable components.UISystemScreenDraggable: A specialized version of UISystemScreen that adds support for draggable screens. Combines the functionalities of UISystemScreen and DraggableUIComponent.UISystemEvents: Defines various events (e.g., opening, closing, registering screens) that are used to communicate between different components through the event bus.This UI system offers a highly modular and scalable architecture, enabling developers to manage complex UI interactions with ease. The use of an event-driven design allows for decoupled components, making it easier to expand and maintain the system over time.UISystemEventBus: The event bus that handles the publishing and subscribing of UI events. This enables a decoupled communication system between UI components.How to Use the UI System1. Setting Up Screens1. Create a UIScreenConfig:- Right-click in the Project window and go to Create -> UI -> UIScreenConfig.- Configure the UIScreenConfig:- Screen ID: A unique string identifier for the screen (Will be generated automatically).- Can Be Closed: A boolean determining whether this screen can be closed by the user.- Is Initial Screen: Whether this screen is the first screen to open when the system starts.2. Create a Screen GameObject:- Create a new UI Canvas in the scene (representing the UI screen).- Attach a component that extends from UISystemScreen (or UISystemScreenDraggable if it is a draggable screen) to this GameObject.3. Assign the UIScreenConfig:- Assign the UIScreenConfig asset you created to the screen by attaching it to the UISystemScreen component.2. Managing Screens1. Open Screens:- Screens can be opened in two ways:- Exclusive: Opens a screen and closes all other screens.- Additive: Opens a screen while keeping the current screens active.Example:// Open a screen exclusivelyUISystemEventBus.Publish(new UIScreenOpenEvent(screenConfig, true));// Open a screen additivelyUISystemEventBus.Publish(new UIScreenOpenEvent(screenConfig, false));2. Close Screens:- You can close a specific screen, close the last opened screen, or close all screens.Example:// Close a specific screenUISystemEventBus.Publish(new UIScreenCloseEvent(screenConfig));// Close the last opened screenUISystemEventBus.Publish(new UIScreenCloseLastEvent());// Close all screensUISystemEventBus.Publish(new UIScreenCloseAllEvent());3. Pause Menu Integration:- For in-game UIs, you can integrate a pause menu by using the UISystemManagerInGame. This manager includes additional functionality to handle the escape key and toggle the pause menu.3. Adding Draggable Screens1. Draggable Screens:- To create draggable screens, use the UISystemScreenDraggable component. Ensure the screen has a RectTransform and attach the DraggableUIComponent to handle drag events.2. Configuring Drag Area:- The DraggableUIComponent includes an optional draggableArea property. Assign a RectTransform to this field to constrain the draggable screen within a specific area.4. Screen Hierarchy and History1. Hierarchy Management:- The system automatically manages the hierarchy of screens through UIScreenNode objects. Screens can have parent-child relationships, and these relationships are reflected in the screen's Transform hierarchy.2. Screen History:- The system tracks the history of opened screens in a stack. You can navigate back to previously opened screens by closing the current screen, which automatically restores the previous screen in the history.Customization1. Adding New Screen Types:- You can extend the UISystemScreen class to create custom behavior for different screen types.- Example: If you want a specialized in-game menu, you can create a class that extends UISystemScreen and adds new features specific to in-game behavior.2. Custom Screen Transitions:- You can extend or modify the UIScreenTransitionManager to add new types of screen transitions (e.g., sliding animations, fades, etc.).Troubleshooting1. Screen Not Showing:- Ensure that the screen's UIScreenConfig is correctly assigned.- Verify that the Canvas containing the screen is active and enabled.2. Screen Not Draggable:- Ensure the DraggableUIComponent is attached and configured correctly.- Verify that the draggableArea is correctly assigned (if you want to restrict the draggable area).Future Improvements- Animation Integration: Adding more detailed animations for screen transitions.- Dynamic Loading: Support for dynamically loading screens.- Improved Drag Constraints: Add more complex drag constraints, such as snapping the screen to specific positions.- Custom screen size: Add custom screen resize during game to modify screen sizesUnity Version Compatibility: Works with Unity 2020.3 or higher (LTS preferred)Key Features:Event-Driven Architecture: Allows screens and components to react to system-wide events without direct dependencies, providing scalability and flexibility.Screen Transition Management: Includes options for both additive (keep current screens active) and exclusive (close all other screens) transitions, giving you control over how screens are displayed.Draggable UI Support: Offers draggable UI components with customizable drag areas to ensure seamless interaction for users.Configurable Screen Behavior: UIScreenConfig assets allow developers to define the behavior and settings of each screen (e.g., can the screen be closed, is it the initial screen, etc.) directly in the Unity editor.Screen Hierarchy and History: Handles parent-child relationships between screens, making it easy to nest screens within each other. The screen history allows users to navigate back to previous screens, maintaining a stack of opened screens.In-Game and Main Menu Managers: Includes dedicated managers for handling in-game UIs and main menus, providing a specialized solution for different parts of your project.Easy Extensibility: Developers can extend or replace any part of the system (e.g., adding custom screen types, transitions, or additional behaviors) thanks to the modular and open architecture.Performance Optimized: Designed to ensure that there’s minimal overhead, which makes the system ideal for both resource-constrained mobile platforms and high-end desktop applications.Dependencies:Text Mesh Pro: This package uses the com.unity.textmeshpro package.I used AI (DALL-E) to create my Icon, Card, Cover and Social Media image!