Skip to content

Game.UI.Editor.InspectorPanelSystem

Assembly: Assembly-CSharp
Namespace: Game.UI.Editor

Type: class

Base: EditorPanelSystemBase

Summary:
InspectorPanelSystem is the in-game editor inspector used by the Cities: Skylines 2 editor mode. It builds and refreshes the inspector UI for selected prefabs, components, meshes and sub-objects, provides actions for locating/moving/cloning instances, supports adding components, saving/sharing assets, editing localization entries and thumbnail/icons, and handles related input bindings and overrides (color variations, emissive settings, etc.). The system integrates with PrefabSystem, ToolSystem and other editor subsystems to reflect and apply changes to prefab data and runtime entities.


Fields

  • private PrefabSystem m_PrefabSystem
    Stores reference to the game's PrefabSystem (used to query, update and duplicate prefabs and map prefab entities).

  • private ToolSystem m_ToolSystem
    Reference to the ToolSystem (used to activate editor tools and query selected tool/entity).

  • private ObjectToolSystem m_ObjectTool
    Reference to the object editing tool used to move/clone/create object instances.

  • private CameraUpdateSystem m_CameraUpdateSystem
    Reference to camera control system used by locate action.

  • private EditorAssetUploadPanel m_AssetUploadPanel
    Panel used for uploading/sharing assets to the platform.

  • private ProxyAction m_MoveAction
    Input action wrapper for the "Move Selected" editor hotkey.

  • private ProxyAction m_CloneAction
    Input action wrapper for the "Clone" editor hotkey.

  • private ProxyAction m_AutoAlignAction
    Input action wrapper for "Auto Align" hotkey.

  • private ProxyAction m_AutoConnectAction
    Input action wrapper for "Auto Connect" hotkey.

  • private ProxyAction m_AlignXAction
    Input action wrapper for "Align X" hotkey.

  • private ProxyAction m_AlignYAction
    Input action wrapper for "Align Y" hotkey.

  • private ProxyAction m_AlignZAction
    Input action wrapper for "Align Z" hotkey.

  • private EditorGenerator m_EditorGenerator = new EditorGenerator()
    Generator used to construct widget lists from objects/reflection.

  • private Button[] m_MeshFooter
    Predefined footer button set when a mesh is selected.

  • private Button[] m_InstanceFooter
    Predefined footer button set used for instance mode.

  • private Button[] m_PrefabFooter
    Predefined footer button set used for prefabs.

  • private Button[] m_CustomAssetFooter
    Footer used for saving custom assets.

  • private Entity m_CurrentSelectedEntity
    Currently selected runtime Entity (for instance mode). Entity.Null if none.

  • [CanBeNull] private object m_SelectedObject
    The object currently inspected in the panel. Can be a PrefabBase, Component, ObjectMeshInfo, ObjectSubObjectInfo or other supported object.

  • [CanBeNull] private object m_ParentObject
    Parent object for m_SelectedObject (usually the owning PrefabBase).

  • [CanBeNull] private ObjectSubObjectInfo m_LastSubObject
    Previously-selected sub-object (used for align/connect operations).

  • [CanBeNull] private ObjectSubObjectInfo m_CurrentSubObject
    Currently-selected sub-object (used for align/connect operations).

  • [CanBeNull] private LocalizedString m_SelectedName = null
    Cached localized display name for m_SelectedObject used to avoid unnecessary title updates.

  • [CanBeNull] private LocalizedString m_ParentName = null
    Cached localized display name for m_ParentObject.

  • private List<object> m_SectionObjects = new List<object>()
    List of objects representing inspector sections (m_SelectedObject plus its components / mesh components).

  • private Dictionary<PrefabBase, LocalizationFields> m_WipLocalization = new Dictionary<PrefabBase, LocalizationFields>()
    WIP localization entries per prefab while editing before saving.

  • private PdxSdkPlatform m_Platform
    Platform integration reference used when sharing/uploading assets.

(Inner types) - private enum Mode { Instance, Prefab }
Determines inspector mode: editing a placed instance (with entity) vs editing a prefab template.

  • private struct LocalizationFields
    Holds per-prefab LocalizationField instances (name and description) and a Clone method.

Properties

  • private Mode mode { get; }
    Determines whether the inspector is in Instance or Prefab mode. Instance when a runtime Entity is selected or when the selected object is not a top-level PrefabBase; Prefab when a top-level PrefabBase is selected and no entity.

  • private bool canMoveSelected { get; }
    True when the currently selected entity can be moved (entity has PrefabRef and Object component and is the tool's selected entity).

  • private bool canCloneSelected { get; }
    True when the currently selected entity can be cloned (entity has PrefabRef and Object component).

  • private bool canAlignSelected { get; }
    True when both m_CurrentSubObject and m_LastSubObject are non-null (alignment/connect operations available).


Constructors

  • public InspectorPanelSystem()
    Default system constructor. Initializes the system instance. (No special parameters; initialization of many pointers happens in OnCreate.)

Methods

  • [Preserve] protected override void OnCreate() : System.Void
    Sets up subsystem references, finds input actions, initializes footer button arrays and registers to platform registration events. Called when the system is created.

  • [Preserve] protected override void OnStopRunning() : System.Void
    Cleans up active subpanel, disables input actions and resets overrides when the system stops running.

  • protected override void OnValueChanged(IWidget widget) : System.Void
    Called when a widget value changes. Detects color variation and emissive fields, triggers appropriate override updates, and refreshes parent prefab state.

  • [Preserve] protected override void OnUpdate() : System.Void
    Per-frame update: refreshes panel content and handles input actions.

  • public bool SelectEntity(Entity entity) : bool
    Selects a runtime entity for inspection. Updates m_CurrentSelectedEntity and resolves selected object/parent and sub-object references. Returns true if selection valid.

  • public void SelectPrefab(PrefabBase prefab) : void
    Selects a prefab template for editing (switches to prefab mode).

  • private bool SelectObjectForEntity(Entity entity) : bool
    Resolves and sets m_SelectedObject/m_ParentObject for a given entity if it corresponds to a prefab object or nested sub-object. Handles editor containers, effect sources, activity locations and object sub-objects.

  • public bool SelectMesh(Entity entity, int meshIndex) : bool
    Selects a mesh instance (submesh) from a prefab instance and resolves the corresponding ObjectMeshInfo when available.

  • private bool FindObjectMeshInfo(ObjectGeometryPrefab prefab, PrefabBase meshPrefab, out ObjectMeshInfo info) : bool
    Helper to find the corresponding ObjectMeshInfo entry for a given mesh prefab.

  • private void RefreshContent() : void
    Refreshes title and section contents of the inspector (delegates to RefreshTitle and RefreshSections).

  • private void RefreshTitle() : void
    Updates panel title based on m_SelectedObject and m_ParentObject localized names (caches names to avoid redundant updates).

  • [CanBeNull] private LocalizedString GetObjectName([CanBeNull] object obj) : LocalizedString
    Gets a localized display name for an object (prefab label when object is PrefabBase, otherwise type name).

  • private void RefreshSections() : void
    Builds inspector sections for the selected object and its components (uses EditorGenerator and reflection). Adds localization fields for prefabs and sets up delete handlers / active accessors. Rebuilds children widgets and footer.

  • private void RefreshFooter(IList<IWidget> panelChildren) : void
    Appends appropriate footer button rows depending on selected object (mesh, instance mode, prefab mode) and shows custom asset save option for non-builtin prefabs.

  • public static void DisableAllFields(IWidget widget) : void
    Recursively disables all editable widgets within a widget tree. Used to prevent editing builtin asset fields.

  • private IEnumerable<object> GetSectionObjects() : IEnumerable<object>
    Enumerates objects that should appear as inspector sections: selected object, prefab components, and mesh component entries (for ObjectMeshInfo).

  • private static ITypedValueAccessor<bool> GetActiveAccessor(ComponentBase component)
    Returns an accessor allowing the editor section to toggle component.active property.

  • private void ShowAddComponentPicker() : void
    Opens a type picker subpanel to add a component to the selected prefab/mesh.

  • private void OnDuplicate() : void
    Duplicates the selected prefab template. If in instance mode, activates the prefab tool with the duplicated prefab; otherwise selects the duplicated prefab in the inspector.

  • private void OnAddComponent(Type type) : void
    Callback to add a component to the selected prefab/mesh when chosen from the type picker.

  • private IEnumerable<Item> GetComponentTypeItems() : IEnumerable<Item>
    Enumerates valid component types that can be added to the currently selected prefab/mesh (filters built-in, hidden and incompatible types).

  • private void HandleInput() : void
    Enables/handles configured input actions (move/clone/align/connect/align axes) each frame; invokes respective methods when actions are performed.

  • private void MoveSelected() : void
    Starts the object tool in move mode for the current entity and makes it the active tool.

  • private void CloneSelected() : void
    Prepares the object tool for creating a clone of the current object instance.

  • private void AutoAlign() : void
    Aligns the current sub-object to the last sub-object by choosing the axis with the smallest offset and snapping that axis.

  • private void AutoConnect() : void
    Attempts to automatically connect two sub-objects by using their geometry bounds and the dominant axis difference to offset positions so they butt up to each other.

  • private void AlignX() : void
    Snaps current sub-object X position to last sub-object X position.

  • private void AlignY() : void
    Snaps current sub-object Y position to last sub-object Y position.

  • private void AlignZ() : void
    Snaps current sub-object Z position to last sub-object Z position.

  • private void UpdateParent(bool moveSubObjects) : void
    Updates and marks dirty the parent prefab and/or mesh when child sub-object or mesh changes. If moveSubObjects is true, also applies movement deltas to relevant sub-object data.

  • private void MoveSubObjects(PrefabBase prefab) : void
    When a submesh has been moved/rotated, updates any dependent sub-objects, sub-areas, lanes, nets and effects on the parent prefab to preserve relative transforms. Handles translation-only and full transform cases properly.

  • private void OnLocate() : void
    Centers the camera on the selected entity's position; handles cinematic camera special case.

  • private bool IsColorVariationField(IWidget widget, out int variationSetIndex, out int colorIndex, out RenderPrefabBase mesh) : bool
    Detects if a widget corresponds to a color-variation ColorField and returns indices and the mesh used for override updates.

  • private bool IsEmissiveField(IWidget widget, out int singleLightIndex, out int multiLightIndex, out RenderPrefabBase mesh) : bool
    Detects if a widget corresponds to an emissive field (single or multi lights) and returns indices and the mesh used for procedural upload overrides.

  • private void OnColorVariationChanged(Entity entity, RenderPrefabBase mesh, int variationSetIndex, int colorIndex) : void
    Notifies MeshColorSystem to set an override for the given entity/mesh/color indices.

  • private void OnEmissiveChanged(Entity entity, RenderPrefabBase mesh, int singleLightIndex, int multiLightIndex) : void
    Notifies ProceduralUploadSystem to set emissive overrides for the given entity/mesh/light indices.

  • private void ShowSaveAssetPanel() : void
    Opens SaveAssetPanel pre-filled with available custom assets and the current prefab (if applicable). Callback invokes OnSaveAsset.

  • private IEnumerable<AssetItem> GetCustomAssets() : IEnumerable<AssetItem>
    Enumerates user assets available for save/overwrite, and includes the current builtin asset's editable copy if present.

  • private bool TryGetAssetItem(PrefabAsset asset, out AssetItem item) : bool
    Helper to build an AssetItem from a PrefabAsset (loads prefab, fetches thumbnail and metadata). Catches exceptions and logs failures.

  • private void OnSaveAsset(string name, Colossal.Hash128? overwriteGuid, Action<PrefabAsset> callback = null) : void
    Handles save/overwrite confirmation flow and delegates to SaveAsset.

  • private void SaveAsset(string name, PrefabAsset existing = null, Action<PrefabAsset> callback = null) : void
    Saves or overwrites a prefab asset: duplicates the prefab when saving a builtin asset, writes icons, saves prefab asset and localization (for non-builtin assets), and unlocks the platform achievement for creating an asset.

  • private void ShowShareAssetPanel() : void
    Opens a variant of SaveAssetPanel for sharing; when saved, OnShareAsset uploads the asset using EditorAssetUploadPanel.

  • private void OnShareAsset(PrefabAsset asset) : void
    Shows the upload panel for a prefab asset.

  • private PrefabBase DuplicatePrefab(PrefabBase oldPrefab) : PrefabBase
    Duplicates a prefab preserving any in-progress localization edits tracked in m_WipLocalization and clears the asset reference on the duplicate.

  • public void ShowThumbnailPicker(LoadAssetPanel.LoadCallback callback) : void
    Opens a thumbnail picker built from user images and invokes callback with selected image hash.

  • private void SaveIcons(PrefabBase prefab, string name) : void
    Saves non-builtin icon/image assets referenced by the prefab into the prefab asset database and rewires references to the saved images.

  • private void BuildLocalizationFields(PrefabBase prefab, List<IWidget> widgets) : void
    Ensures localization fields exist in m_WipLocalization for prefab, initializes from existing locale assets, and adds localized name/description UI groups to the widgets list.

  • private List<LocalizationField.LocalizationFieldEntry> InitializeLocalization(PrefabBase prefab, string key) : List<LocalizationField.LocalizationFieldEntry>
    Collects existing localized entries for a given localization key from user or global locale assets and returns them as a list.

  • private void SaveLocalization(PrefabBase prefab, string name) : void
    Persists edited localization entries (from m_WipLocalization) into new LocaleAsset files under the user asset database for the saved prefab. Supports additional keys for services, subservices and upgrades where applicable.

  • [Preserve] public InspectorPanelSystem() : .ctor
    Public constructor (present in source), typical no-op (initialization is done in OnCreate).


Usage Example

[Preserve]
protected override void OnCreate()
{
    base.OnCreate();

    // typical initialization performed by InspectorPanelSystem:
    m_PrefabSystem = base.World.GetOrCreateSystemManaged<PrefabSystem>();
    m_ToolSystem = base.World.GetOrCreateSystemManaged<ToolSystem>();
    m_ObjectTool = base.World.GetOrCreateSystemManaged<ObjectToolSystem>();
    m_CameraUpdateSystem = base.World.GetOrCreateSystemManaged<CameraUpdateSystem>();
    m_AssetUploadPanel = base.World.GetOrCreateSystemManaged<EditorAssetUploadPanel>();

    // find input actions used by the inspector
    m_MoveAction = InputManager.instance.FindAction("Editor", "Move Selected");
    m_CloneAction = InputManager.instance.FindAction("Editor", "Clone");
    // ...and so on
}

If you want, I can also: - produce a smaller "quick reference" md with only public-facing methods and common usage snippets; or - generate XML-like signatures for all methods and fields for quick copy into API docs. Which would you prefer?