CharacterEditor

Custom Unity Inspector editor for the Character behaviour. Extends ParagonBehaviourEditor to display character info (name, possessor) and configure the subsystem drawer with custom icons, names, priorities, and removability rules for each character component type.

Definition

Namespace: Paragon.Townskeep.CharacterSystem.Editor Assembly: Townskeep.Editor.dll

[CustomEditor(typeof(Character))]
public class CharacterEditor : ParagonBehaviourEditor

Inheritance: OdinEditorParagonEditorParagonEditor<ParagonBehaviour>ParagonBehaviourEditorCharacterEditor

Remarks

CharacterEditor customizes how Character instances appear in the Inspector. It does two key things:

  1. Header info — Displays the character's name and possessor status in the existing header layout

  2. Subsystem drawer configuration — Configures the ParagonSubsystemDrawer with per-component metadata:

    • Icons — Visual icons for each component type (e.g., camera icon for CharacterCamera)

    • Names — Friendly display names (e.g., "Motor" instead of "CharacterMotor")

    • Priority — Display ordering in the subsystem list

    • Removability — Whether a component can be removed by the user (core components like Motor and Camera cannot be removed unless debug mode is enabled)

Component Metadata Registry

The editor maintains a static dictionary mapping component types to their display metadata:

Component Type
Display Name
Priority
Icon
Can Remove

CharacterMotor

Motor

0

CHIP

No

CharacterCamera

Camera

1

CAMERA

No

CharacterAnimator

Animator

2

ANIMATOR

No

CharacterController

Controller

3

GAMEPAD

No

CharacterInteractor

Interactor

4

FINGER

Yes

CharacterInventory

Inventory

5

UI_CANVAS_GROUP

Yes

CharacterNetwork

Network

6

SATELLITE

No

circle-info

Components not in the metadata registry default to: icon = LAYERS, priority = int.MaxValue (sorted last), name = nicified type name with "Character" prefix removed.

circle-info

When Character.DebugEnabled is true, all components can be removed regardless of the canBeRemoved flag in the metadata.

Quick Lookup

Goal
How

Add a new component to the registry

Add entry to componentMetaData dictionary

Change component display order

Modify the priority value (lower = higher in list)

Make a component non-removable

Set canBeRemoved: false in metadata

Allow removal in debug mode

Already handled — GetCanBeRemoved checks character.DebugEnabled

Methods

OnCreateGUI (override)

Sets up the Inspector UI. Populates the header with character name/possessor info and configures the subsystem drawer with icon, priority, name, and removability getters.

circle-exclamation

OnInspectorGUI (override)

Empty override — all rendering is handled by the UIElements-based OnCreateGUI and the subsystem drawer.

GetName (static)

Returns the display name for a component type. Falls back to nicifying the type name with "Character" removed.

GetPriority (static)

Returns the sort priority for a component type. Falls back to int.MaxValue.

GetIconType (static)

Returns the ParagonIconType for a component type. Falls back to LAYERS.

GetCanBeRemoved

Returns whether a component type can be removed. Returns true if debug mode is enabled or if the type's metadata allows removal.

Extension Points

To add a new character component to the Inspector:

  1. Add the component type to the componentMetaData dictionary with name, priority, icon, and removability

  2. The subsystem drawer will automatically pick up the new entry

Common Pitfalls

circle-exclamation
circle-exclamation

See Also

Last updated