Skip to content

Repository files navigation

GameLovers UI Service

Unity VersionLicense: MITVersion

Quick Links: Installation | Quick Start | Documentation | Examples | Troubleshooting

UiService Demo

Why Use This Package?

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:

ProblemSolution
Scattered UI logicCentralized service manages all UI lifecycle (load → open → close → unload)
Memory management headachesAddressables integration with automatic asset loading/unloading
Rigid UI hierarchiesLayer-based organization with flexible depth sorting
Duplicated boilerplateFeature composition system extends behavior without inheritance complexity
Async loading complexityUniTask-powered async operations with cancellation support
No visibility into UI stateEditor windows for real-time analytics, hierarchy debugging, and configuration
Difficult testingInjectable 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.

Key Features

  • 🎭 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
  • 🛠️ Editor Tools - Presenter Manager window for real-time debugging and monitoring
  • 📱 Responsive Design - Built-in support for device safe areas (e.g. iPhone dynamic island)

System Requirements

Dependencies are automatically resolved when installing via Unity Package Manager.

Using the backdrop blur needs one manual step: add UiBackdropBlurRendererFeature to your Universal Renderer asset (Add Renderer Feature), not just the presenter component. Without it the blur silently does nothing. See URP Rendering Features.

Compatibility Matrix

Unity VersionStatusNotes
6000.5.x (Unity 6)✅ Fully TestedPrimary development target
6000.3.x (Unity 6)✅ Fully Tested
6000.0.x (Unity 6)✅ Fully TestedFully supported
2022.3 LTS⚠️ UntestedMay require minor adaptations
PlatformStatusNotes
Standalone (Windows/Mac/Linux)✅ SupportedFull feature support
WebGL✅ SupportedRequires UniTask (no Task.Delay)
Mobile (iOS/Android)✅ SupportedFull feature support
Console⚠️ UntestedShould work with Addressables setup

Installation

Via Unity Package Manager (Recommended)

  1. Open Unity Package Manager (WindowPackage Manager)
  2. Click the + button and select Add package from git URL
  3. Enter the following URL:
    https://github.com/CoderGamester/com.gamelovers.uiservice.git
    

Via manifest.json

Add the following line to your project's Packages/manifest.json:

{
"dependencies": {
"com.gamelovers.uiservice": "https://github.com/CoderGamester/com.gamelovers.uiservice.git"
}
}

Via OpenUPM

openupm add com.gamelovers.uiservice

Documentation

DocumentDescription
Getting StartedInstallation, setup, and first presenter
Core ConceptsPresenters, layers, sets, features
API ReferenceComplete API documentation
Advanced TopicsAnalytics, performance, helper views
URP Rendering FeaturesCamera stacking, backdrop blur, render-texture authoring, layering hazards
TroubleshootingCommon issues and solutions

Key Components

ComponentResponsibility
IUiServicePublic API surface for all UI operations
UiServiceCore implementation managing lifecycle, layers, and state
UiPresenterBase class for all UI views with lifecycle hooks
UiConfigsScriptableObject storing UI configuration and sets
IUiAssetLoaderInterface for custom asset loading strategies
AddressablesUiAssetLoaderHandles Addressables integration for async loading
PrefabRegistryUiAssetLoaderSimple loader for direct prefab references
ResourcesUiAssetLoaderLoads UI from Unity's Resources folder
PresenterFeatureBaseBase class for composable presenter behaviors
UiInstanceIdEnables multiple instances of the same presenter type

Quick Start

1. Create UI Configuration

  1. Right-click in Project View
  2. Navigate to CreateScriptableObjectsConfigsUiConfigs
  3. Configure your UI presenters in the created asset

2. Initialize the UI Service

usingUnityEngine;usingGameLovers.UiService;publicclassGameInitializer:MonoBehaviour{[SerializeField]privateUiConfigs_uiConfigs;privateIUiServiceInit_uiService;voidStart(){_uiService=newUiService();_uiService.Init(_uiConfigs);}}

3. Create Your First UI Presenter

usingUnityEngine;usingGameLovers.UiService;publicclassMainMenuPresenter:UiPresenter{[SerializeField]privateButton_playButton;protectedoverridevoidOnInitialized(){_playButton.onClick.AddListener(OnPlayClicked);}protectedoverridevoidOnOpened(){Debug.Log("Main menu opened!");}protectedoverridevoidOnClosed(){Debug.Log("Main menu closed!");}privatevoidOnPlayClicked(){Close(destroy:false);}}

4. Open and Manage UI

// Open UIvarmainMenu=await_uiService.OpenUiAsync<MainMenuPresenter>();// Check visibilityif(_uiService.IsVisible<MainMenuPresenter>()){Debug.Log("Main menu is visible");}// Close UI_uiService.CloseUi<MainMenuPresenter>();

📖 For complete setup guide, see Getting Started


Examples

The package includes sample implementations in the Samples~ folder.

Importing Samples

  1. Open Unity Package Manager (WindowPackage Manager)
  2. Select "GameLovers UiService" package
  3. Navigate to the "Samples" tab
  4. Click "Import" next to the sample you want

Available Samples

SampleDescription
BasicUiFlowBasic presenter lifecycle and button interactions
DataPresenterData-driven UI with UiPresenter<T>
DelayedPresenterTime and animation delay features
UiToolkitUI Toolkit (UI Elements) integration
DelayedUiToolkitMultiple features combined
UiSetsGroup multiple UIs for batch operations (e.g., game HUD)
MultiInstanceCreate multiple instances of the same presenter type
CustomFeaturesCreate custom presenter features (fade, scale, sound)
AssetLoadingStrategiesCompare PrefabRegistry, Addressables, and Resources loading

Contributing

Contributions are welcome! Report bugs or request features via GitHub Issues. For development setup, architecture, assembly conventions, and coding standards, see AGENTS.md.


Related docs

DocumentPurpose
docs/README.mdFull documentation (getting started, concepts, API, advanced)
AGENTS.mdContributor/agent guide (architecture, gotchas, workflows)
CHANGELOG.mdVersion history

Support

License

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!

About

This package provides a service to help centralize the control of Unity's UI (UGUI and UiToolkit)

Topics

Resources

Stars

7 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages