Quick Links: Installation | Quick Start | Documentation | Examples | Troubleshooting
Managing UI in Unity games often becomes a tangled mess of direct references, scattered open/close logic, and manual lifecycle management. This UI Service solves these pain points:
| Problem | Solution |
|---|---|
| Scattered UI logic | Centralized service manages all UI lifecycle (load β open β close β unload) |
| Memory management headaches | Addressables integration with automatic asset loading/unloading |
| Rigid UI hierarchies | Layer-based organization with flexible depth sorting |
| Duplicated boilerplate | Feature composition system extends behavior without inheritance complexity |
| Async loading complexity | UniTask-powered async operations with cancellation support |
| No visibility into UI state | Editor windows for real-time analytics, hierarchy debugging, and configuration |
| Difficult testing | Injectable interfaces (IUiService, IUiAssetLoader) and built-in loaders enable easy mocking |
Built for production: Used in real games with WebGL, mobile, and desktop support. Zero per-frame allocations in hot paths.
- π UI Model-View-Presenter Pattern - Clean separation of UI logic with lifecycle management
- π¨ UI Toolkit Support - Compatible with both uGUI and UI Toolkit
- π§© Feature Composition - Modular feature system for extending presenter behavior
- π Async Loading - Load UI assets asynchronously with UniTask support
- π¦ UI Group Organization - Organize UI elements by depth layers and in groups for batch operations
- πΎ Memory Management - Efficient loading/unloading of UI assets with Unity's Addressables system
- π Analytics & Performance Tracking - Optional analytics system with dependency injection
- π οΈ Editor Tools - Powerful editor windows for debugging and monitoring
- π± Responsive Design - Built-in support for device safe areas (e.g. iPhone dynamic island)
- Unity (v6.0+) - To run the package
- Unity Addressables (v2.6.0+) - For async asset loading
- UniTask (v2.5.10+) - For efficient async operations
Dependencies are automatically resolved when installing via Unity Package Manager.
| Unity Version | Status | Notes |
|---|---|---|
| 6000.3.x (Unity 6) | β Fully Tested | Primary development target |
| 6000.0.x (Unity 6) | β Fully Tested | Fully supported |
| 2022.3 LTS | May require minor adaptations |
| Platform | Status | Notes |
|---|---|---|
| Standalone (Windows/Mac/Linux) | β Supported | Full feature support |
| WebGL | β Supported | Requires UniTask (no Task.Delay) |
| Mobile (iOS/Android) | β Supported | Full feature support |
| Console | Should work with Addressables setup |
- Open Unity Package Manager (
WindowβPackage Manager) - Click the
+button and selectAdd package from git URL - Enter the following URL:
https://github.com/CoderGamester/com.gamelovers.uiservice.git
Add the following line to your project's Packages/manifest.json:
{
"dependencies": {
"com.gamelovers.uiservice": "https://github.com/CoderGamester/com.gamelovers.uiservice.git"
}
}openupm add com.gamelovers.uiservice| Document | Description |
|---|---|
| Getting Started | Installation, setup, and first presenter |
| Core Concepts | Presenters, layers, sets, features |
| API Reference | Complete API documentation |
| Advanced Topics | Analytics, performance, helper views |
| Troubleshooting | Common issues and solutions |
Runtime/
βββ Loaders/
β βββ IUiAssetLoader.cs # Asset loading interface
β βββ AddressablesUiAssetLoader.cs # Addressables implementation
β βββ PrefabRegistryUiAssetLoader.cs # Direct prefab references
β βββ ResourcesUiAssetLoader.cs # Resources.Load implementation
βββ IUiService.cs # Public API interface
βββ UiService.cs # Core implementation
βββ UiPresenter.cs # Base presenter classes
βββ UiConfigs.cs # Configuration ScriptableObject
βββ Features/ # Composable features
β βββ TimeDelayFeature.cs
β βββ AnimationDelayFeature.cs
β βββ UiToolkitPresenterFeature.cs
βββ Views/ # Helper components
Editor/
βββ UiConfigsEditor.cs # Enhanced inspector
βββ UiAnalyticsWindow.cs # Performance monitoring
βββ UiServiceHierarchyWindow.cs # Live debugging
| Component | Responsibility |
|---|---|
| IUiService | Public API surface for all UI operations |
| UiService | Core implementation managing lifecycle, layers, and state |
| UiPresenter | Base class for all UI views with lifecycle hooks |
| UiConfigs | ScriptableObject storing UI configuration and sets |
| PrefabRegistryConfig | Map address keys to UI Prefabs for direct reference |
| IUiAssetLoader | Interface for custom asset loading strategies |
| AddressablesUiAssetLoader | Handles Addressables integration for async loading |
| PrefabRegistryUiAssetLoader | Simple loader for direct prefab references |
| ResourcesUiAssetLoader | Loads UI from Unity's Resources folder |
| PresenterFeatureBase | Base class for composable presenter behaviors |
| UiInstanceId | Enables multiple instances of the same presenter type |
- Right-click in Project View
- Navigate to
CreateβScriptableObjectsβConfigsβUiConfigs - Configure your UI presenters in the created asset
using UnityEngine;
using GameLovers.UiService;
public class GameInitializer : MonoBehaviour
{
[SerializeField] private UiConfigs _uiConfigs;
private IUiServiceInit _uiService;
void Start()
{
_uiService = new UiService();
_uiService.Init(_uiConfigs);
}
}using UnityEngine;
using GameLovers.UiService;
public class MainMenuPresenter : UiPresenter
{
[SerializeField] private Button _playButton;
protected override void OnInitialized()
{
_playButton.onClick.AddListener(OnPlayClicked);
}
protected override void OnOpened()
{
Debug.Log("Main menu opened!");
}
protected override void OnClosed()
{
Debug.Log("Main menu closed!");
}
private void OnPlayClicked()
{
Close(destroy: false);
}
}// Open UI
var mainMenu = await _uiService.OpenUiAsync<MainMenuPresenter>();
// Check visibility
if (_uiService.IsVisible<MainMenuPresenter>())
{
Debug.Log("Main menu is visible");
}
// Close UI
_uiService.CloseUi<MainMenuPresenter>();π For complete setup guide, see Getting Started
The package includes sample implementations in the Samples~ folder.
- Open Unity Package Manager (
WindowβPackage Manager) - Select "UI Service" package
- Navigate to the "Samples" tab
- Click "Import" next to the sample you want
| Sample | Description |
|---|---|
| BasicUiFlow | Basic presenter lifecycle and button interactions |
| DataPresenter | Data-driven UI with UiPresenter<T> |
| DelayedPresenter | Time and animation delay features |
| UiToolkit | UI Toolkit (UI Elements) integration |
| DelayedUiToolkit | Multiple features combined |
| Analytics | Performance tracking integration |
We welcome contributions! Here's how you can help:
- Use the GitHub Issues page
- Include Unity version, package version, and reproduction steps
- Attach relevant code samples, error logs, or screenshots
- Fork the repository on GitHub
- Clone your fork:
git clone https://github.com/yourusername/com.gamelovers.uiservice.git - Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes with tests
- Commit:
git commit -m 'Add amazing feature' - Push:
git push origin feature/amazing-feature - Create a Pull Request
- Follow C# Coding Conventions
- Add XML documentation to all public APIs
- Include unit tests for new features
- Update CHANGELOG.md for notable changes
- Issues: Report bugs or request features
- Discussions: Ask questions and share ideas
- Changelog: See CHANGELOG.md for version history
This project is licensed under the MIT License - see the LICENSE.md file for details.
Made with β€οΈ for the Unity community
If this package helps your project, please consider giving it a β on GitHub!
