Skip to content

Game.UI.UIUpdateSystem

Assembly:
Namespace: Game.UI

Type: class

Base: GameSystemBase

Summary:
A small game system responsible for executing the UI update phase. On each frame update it delegates to the central UpdateSystem with the SystemUpdatePhase.UIUpdate phase so that UI-related subsystems and components run their update logic in the correct phase. The class is marked with Preserve attributes on its lifecycle methods/constructor to avoid removal by IL2CPP/code stripping in release builds.


Fields

  • private UpdateSystem m_UpdateSystem
    Holds a reference to the game's UpdateSystem instance. This is resolved in OnCreate via World.GetOrCreateSystemManaged() so the UIUpdateSystem can forward UI-phase updates to the central update dispatcher.

Properties

This type does not expose any public properties.

Constructors

  • public UIUpdateSystem()
    Default parameterless constructor. Decorated with [Preserve] to ensure the constructor and type are kept by code-stripping/linking tools (IL2CPP). No custom initialization is performed here; initialization is done in OnCreate.

Methods

  • protected override void OnCreate() : System.Void
    Called when the system is created. Calls base.OnCreate() and retrieves (or creates) the UpdateSystem instance from the World:
    m_UpdateSystem = base.World.GetOrCreateSystemManaged();
    The method is annotated with [Preserve] to prevent removal by the runtime linker.

  • protected override void OnUpdate() : System.Void
    Called every frame (or tick) for this system. It simply forwards the update call to the UpdateSystem with the UI update phase:
    m_UpdateSystem.Update(SystemUpdatePhase.UIUpdate);
    Also annotated with [Preserve].

Usage Example

using UnityEngine.Scripting;

namespace Game.UI;

public class UIUpdateSystem : GameSystemBase
{
    private UpdateSystem m_UpdateSystem;

    [Preserve]
    protected override void OnCreate()
    {
        base.OnCreate();
        m_UpdateSystem = base.World.GetOrCreateSystemManaged<UpdateSystem>();
    }

    [Preserve]
    protected override void OnUpdate()
    {
        m_UpdateSystem.Update(SystemUpdatePhase.UIUpdate);
    }

    [Preserve]
    public UIUpdateSystem()
    {
    }
}

Additional notes: - This system acts as a simple adaptor to ensure UI-phase updates are executed; modders rarely need to modify it directly, but understanding it is useful when adding UI-related systems or hooking into the game's update phases. - The SystemUpdatePhase.UIUpdate enum value indicates the UI update step — use the same phase when scheduling or invoking UI-specific updates so ordering remains consistent.