Game.UI.Editor.EditorSection
Assembly: Assembly-CSharp
Namespace: Game.UI.Editor
Type: class
Base: ExpandableGroup, IDisableCallback
Summary:
EditorSection is a UI widget representing a collapsible/expandable section used in editor UI. It supports an optional delete callback, an optional activatable state via an ITypedValueAccessor
Fields
-
public static readonly UnityEngine.Color kPrefabColor
Default color constant used by editor sections (approx. RGB: 27/85, 64/255, 53/255). Used as a prefab tint. -
private bool m_Active
Internal cached active state (keeps track of whether the section is currently active). Updated in Update(). -
private UnityEngine.Color? m_Color
Backing field for the nullable color property. When changed, triggers property change handling.
Properties
-
[CanBeNull] public System.Action onDelete { get; set; }
Optional callback invoked when the section is requested to be deleted (used by the Bindings trigger "deleteEditorSection" and by UI logic). -
[CanBeNull] public Colossal.UI.Binding.ITypedValueAccessor<bool> active { get; set; }
Optional accessor used to read/set the active state of the section. If provided, the widget exposes activatable behavior and synchronizes m_Active with this accessor. -
public bool primary { get; set; }
Flag indicating whether this section is marked as primary. Written out in WriteProperties. -
[CanBeNull] public UnityEngine.Color? color { get; set; }
Nullable color property for the section. When set to a different value than the current one, it calls SetPropertiesChanged() to notify the UI framework of property changes.
Constructors
public EditorSection()
Default constructor (no explicit constructor implementation in the source file). Standard initialization is inherited from the base ExpandableGroup.
Methods
-
protected override WidgetChanges Update()
: WidgetChanges
Overrides the widget's Update logic to synchronize the widget's internal active flag (m_Active) with the value provided by the active accessor (if present). If the active state changes, it marks properties as changed so UI can refresh. -
protected override void WriteProperties(IJsonWriter writer)
: void
Writes the widget's serializable properties into a JSON writer. Properties emitted include: - "expandable" (true when base.children.Count != 0)
- "deletable" (true when onDelete != null)
- "activatable" (true when active != null)
- "active" (current m_Active)
- "primary" (primary flag)
-
"color" (writes color value or null)
-
public class Bindings : IWidgetBindingFactory
(nested) public IEnumerable<IBinding> CreateBindings(string group, IReader<IWidget> pathResolver, ValueChangedCallback onValueChanged)
: IEnumerable
Returns two trigger bindings for use in UI binding definitions:- A TriggerBinding named "deleteEditorSection" which, when invoked on an EditorSection widget, calls the widget's onDelete callback (if present) and invokes onValueChanged.
- A TriggerBinding named "setEditorSectionActive" which, when invoked with a bool value, sets the widget's active accessor via SetTypedValue(active) (if present) and calls onValueChanged.
Usage Example
// Example: configure an EditorSection instance
var section = new Editor.UI.EditorSection
{
primary = true,
color = UnityEngine.Color.red,
onDelete = () => UnityEngine.Debug.Log("EditorSection deleted")
};
// If you have an ITypedValueAccessor<bool> implementation to drive activation state:
section.active = myBoolAccessor; // myBoolAccessor : ITypedValueAccessor<bool>
Notes: - The Bindings nested class is intended to be registered with the UI binding system so that UI definitions can call "deleteEditorSection" and "setEditorSectionActive" on EditorSection widgets. - Changing color via the color property triggers SetPropertiesChanged() so the UI will reserialize and update visuals.