Get started

From install to your first screen

Install the package, open the UI Setup Manager and show a screen from code. The Tutorial walks through every step with screenshots and videos.

Requirements

Unity2022.3 or newer (the showcase project uses Unity 6)
Addressables1.21.0 or newer, installed automatically as a dependency
UIUGUI (com.unity.ugui). Any content works inside your scenes: Text, TextMeshPro, images, your own components
PlatformsEverything Unity and Addressables support. All animation runs on unscaled time

1. Install the package

In Unity, open Window → Package Manager → + → Add package from git URL… and paste:

Package URL
https://github.com/dawaniyah-games/UiFramework.git?path=Packages/com.dawaniyahgames.uiframework

To pin a version, append #vX.Y.Z (see Releases), or add it to Packages/manifest.json:

Packages/manifest.json
{
  "dependencies": {
    "com.dawaniyahgames.uiframework": "https://github.com/dawaniyah-games/UiFramework.git?path=Packages/com.dawaniyahgames.uiframework#v1.3.6"
  }
}

2. Set up the project

  1. Open Window → UI Framework → UI Setup Manager.
  2. In the General tab press Create Config. Set your script and scene folders and your game's namespaces on the created UiEditorConfig.
  3. Check the Global Canvas Settings in the same tab: every new element scene starts with them.

3. Make your first screen

  1. Elements tab → ➕ New Element → name it MainMenuUiElement → Create. You get the script and a scene laid out as MainMenuUiElementRoot → Canvas → Root.
  2. Build your UI under Root and pick a show and hide animation in the element's Animations section.
  3. States tab → type MainMenuUiState next to New state → ➕. Add the MainMenuUiElement scene to it.
  4. General tab → Build Runtime UiConfig. Run it again after every state or scene change.

4. Show it from code

UiManager creates itself; don't add it to a scene. It loads the generated config from Addressables.

GameBootstrap.cs
using System;
using UiFramework.Runtime.Manager;
using UnityEngine;

public class GameBootstrap : MonoBehaviour
{
    // async void is fine for Unity messages, as long as exceptions are caught and logged.
    private async void Start()
    {
        try
        {
            if (!UiManager.IsInitialized)
            {
                await UiManager.InitializeAsync();
            }

            await UiManager.ShowState<MainMenuUiState>();
        }
        catch (Exception exception)
        {
            Debug.LogError("[GameBootstrap] UI failed to start: " + exception);
        }
    }
}
Press Play

With the Addressables play mode set to Use Asset Database (Window → Asset Management → Addressables → Groups → Play Mode Script), the screen appears right away. For a player build, build Addressables content first.

5. Give the screen its data

Whatever you pass to ShowState reaches every element of the state in Populate. Keep Populate idempotent: it runs again when another state reuses the scene.

MainMenuUiElement.cs
using UiFramework.Core;
using UnityEngine;
using UnityEngine.UI;

public class MainMenuParams : UiPopulationParams
{
    public string PlayerName { get; set; }
}

public class MainMenuUiElement : UiElement
{
    [SerializeField] private Text welcomeLabel;

    public override void Populate(object context = null)
    {
        base.Populate(context);

        MainMenuParams data = context as MainMenuParams;
        if (data == null)
        {
            return;
        }

        welcomeLabel.text = "Welcome back, " + data.PlayerName;
    }
}
Showing it with data
MainMenuParams data = new MainMenuParams();
data.PlayerName = "Alex";

await UiManager.ShowState<MainMenuUiState>(data);
Plain values work too

Context is just an object. Pass a primitive and read it with context is int coins.

Default project layout

All paths are settings on your UiEditorConfig; these are the defaults.

WhatWhere
Element scriptsAssets/Scripts/Ui/UiElements
Element scenesAssets/Scenes/UiElements
State scriptsAssets/Scripts/Ui/UiStates
State definitionsAssets/UiConfigs/UiStateDefinitions
Runtime config (generated)Assets/UiConfigs/RuntimeUiConfig.asset
Global canvas settingsAssets/UiConfigs/UiGlobalCanvasSettings.asset