Skip to content

Game.Tools.ToolOutputSystem

Assembly: Game (inferred)
Namespace: Game.Tools

Type: public class

Base: GameSystemBase

Summary:
ToolOutputSystem is a small game system responsible for forwarding the current tool apply mode (from ToolSystem) into the update pipeline by invoking the UpdateSystem with the appropriate SystemUpdatePhase (ClearTool or ApplyTool). It initializes references to the ToolSystem and UpdateSystem during creation and, each frame, executes the correct UpdateSystem phase based on ToolSystem.applyMode. Methods are annotated with [Preserve] to avoid stripping by the runtime (IL2CPP/linker).


Fields

  • private ToolSystem m_ToolSystem
    Reference to the game's ToolSystem. Acquired in OnCreate via World.GetOrCreateSystemManaged() and used in OnUpdate to read the current applyMode.

  • private UpdateSystem m_UpdateSystem
    Reference to the UpdateSystem. Acquired in OnCreate via World.GetOrCreateSystemManaged() and used to call Update(...) with the appropriate SystemUpdatePhase.

Properties

  • This class does not expose any public properties.
    Used state is stored in private fields and handled internally during OnCreate/OnUpdate.

Constructors

  • public ToolOutputSystem()
    Default parameterless constructor. Nothing is initialized here; initialization of system references is performed in the OnCreate override.

Methods

  • protected override void OnCreate()
    Called when the system is created. Calls base.OnCreate(), then obtains managed system instances for ToolSystem and UpdateSystem using base.World.GetOrCreateSystemManaged(). This ensures the ToolOutputSystem has the required dependencies available before it runs.

  • protected override void OnUpdate()
    Called every frame (or when the system is updated). Reads m_ToolSystem.applyMode and switches on it:

  • If ApplyMode.Clear -> calls m_UpdateSystem.Update(SystemUpdatePhase.ClearTool)
  • If ApplyMode.Apply -> calls m_UpdateSystem.Update(SystemUpdatePhase.ApplyTool) No action is taken for other apply modes (they are not handled in the switch).

Notes: - The class relies on the ApplyMode enum (ToolSystem.applyMode) and SystemUpdatePhase values (ClearTool, ApplyTool). - Methods are marked with [Preserve] to prevent them from being stripped by IL2CPP/linker tooling. - This system acts as a small scheduler/bridge to ensure tool-related update phases run at the correct time.

Usage Example

using UnityEngine.Scripting;

[Preserve]
protected override void OnCreate()
{
    base.OnCreate();
    // Acquire references to the systems this system coordinates
    m_ToolSystem = base.World.GetOrCreateSystemManaged<ToolSystem>();
    m_UpdateSystem = base.World.GetOrCreateSystemManaged<UpdateSystem>();
}

[Preserve]
protected override void OnUpdate()
{
    // Forward the tool apply mode into the UpdateSystem's tool phases
    switch (m_ToolSystem.applyMode)
    {
        case ApplyMode.Clear:
            m_UpdateSystem.Update(SystemUpdatePhase.ClearTool);
            break;
        case ApplyMode.Apply:
            m_UpdateSystem.Update(SystemUpdatePhase.ApplyTool);
            break;
    }
}