Skip to content

Game.UI.Editor.IEditorTool

Assembly: Assembly-CSharp (inferred — game runtime assembly)
Namespace: Game.UI.Editor

Type: interface

Base: IJsonWritable

Summary:
Represents a UI editor tool descriptor used by the in-game editor UI. Exposes identifying metadata (id, icon, uiTag), state flags (disabled, active) and a shortcut string. Provides a default JSON serialization implementation (via IJsonWritable) that writes most metadata fields. This is a C# 8+ default interface implementation — implementers receive the provided Write behavior unless they supply their own.


Fields

  • None
    No private or public fields are declared on this interface.

Properties

  • string id { get; }
    Unique identifier for the editor tool. Used to reference the tool programmatically and in serialization.

  • string icon { get; }
    Icon identifier or path for the tool's UI representation.

  • string uiTag { get; }
    UI tag used to locate or reference the UI element associated with this tool.

  • bool disabled { get; }
    Indicates whether the tool is currently disabled (not available for use).

  • string shortcut { get; }
    Human-readable keyboard shortcut string for the tool.

  • bool active { get; set; }
    Indicates whether the tool is currently active. Writable so the UI or code can toggle the tool state.

Constructors

  • None
    Interfaces do not define constructors. Implementing types provide construction logic.

Methods

  • void IJsonWritable.Write(IJsonWriter writer)
    Default interface implementation of IJsonWritable.Write. Serializes the tool metadata to the provided IJsonWriter in the following sequence:
  • Calls writer.TypeBegin(typeof(IEditorTool).FullName)
  • Writes property "id" and its value
  • Writes property "icon" and its value
  • Writes property "uiTag" and its value
  • Writes property "shortcut" and its value
  • Writes property "disabled" and its value
  • Calls writer.TypeEnd()

Note: The implementation does not write the active property. Implementers can provide their own Write implementation if different serialization is required.

Usage Example

// Simple implementation that relies on the interface's default JSON writer.
public class MyEditorTool : IEditorTool
{
    public string id { get; } = "my_company.my_tool";
    public string icon { get; } = "IconPathOrAtlasKey";
    public string uiTag { get; } = "MyToolButton";
    public bool disabled { get; } = false;
    public string shortcut { get; } = "Ctrl+M";
    public bool active { get; set; }

    // No need to implement IJsonWritable.Write unless custom serialization is desired.
}

{{ Additional notes: - The explicit form void IJsonWritable.Write(IJsonWriter writer) inside the interface is a C# 8+ feature (default interface implementation). It means types implementing IEditorTool automatically get this serialization method unless they override it. - If you need to include the active state in saved JSON, implement IJsonWritable.Write in your concrete type and write that property explicitly. - IJsonWriter is part of the game's JSON writing utilities (Colossal UI binding); ensure you use the same writer contract when performing custom serialization. }}