Skip to content

en architecture editor extensions

nullus-docs-bot edited this page Oct 27, 2026 · 2 revisions

Editor Script Extensions

中文 | English | Docs | Repository

The editor is not closed: a project can ship editor scripts under its own Assets directory to register custom Inspectors, tool windows, and menu items. This page covers the boundaries and entry points.

Assembly split

Source location Output Loaded by
Assets/**/Editor/**/*.cs GameScriptsEditor.dll Editor process only
Assets/**/*.cs (everything else) GameScripts.dll Editor and player builds
Managed/Nullus.Editor Editor scripting API Editor

Editor scripts may reference Nullus.Editor; runtime project code may not.

Extension points

Extension point Base type or attribute
Custom Inspector ComponentEditor with [CustomEditor] and [CanEditMultipleObjects]
Custom tool window EditorWindow with [EditorMenuItem]
Menu item [EditorMenuItem], top level restricted to Window or Tools

Menu items end up next to the built-in panels in the editor's top-level menus.

Editor-side data channel

All reflected detail panels must use Inspector::InspectorPropertyEditor. It owns the single implementation of typed property controls, layouts, registered drawers, mixed/read-only values, references and collections. InspectorView provides selection and prefab actions; ReflectedPropertyEditor adapts document values to a staged SerializedObject without constructing an Inspector panel.

Use ReflectedPropertyEditor::Draw/DrawValues for document values, PropertyEditorContext for an existing serialized stream, and ApplyReflectedEdit for the document's preview/commit/cancel boundary. Pass ranges, drag steps, color semantics and custom drawer keys as metadata. Compact VFX rows use PropertyEditorLayout::ValueOnly inside their own table; numeric, vector, color and enum widgets must not be reimplemented in each panel. Domain layouts, graph canvases and binding selectors can surround the shared controls. SharedPropertyEditor tests enforce the common route.

Scripts never write component objects directly. Reads and writes go through:

serializedObject -> SerializedProperty -> ApplyModifiedProperties()

That path is what makes script editors share the following with built-in editors:

  • The undo stack
  • Prefab override recording
  • Multi-object editing semantics
  • Field type conversion and validation

Bypassing it breaks undo and Prefab semantics and is not a supported usage.

Target types

Target How to declare it
Reflected engine component Use the generated type carrying NativeTypeName
Project script component Use a Nullus.Behaviour subclass

Script components share one native reflected type, so matching is by the script's own full C# name. One script's editor never affects another, and base-class matching for subclasses is not supported.

Priority and conflicts

  • A script editor defaults to a higher priority than the built-in editor, which is how it can override one.
  • A duplicate combination of target type, inheritance rule, and priority fails registration with an explicit error rather than being silently deduplicated.

Error isolation

Exceptions thrown by a script or editor are caught:

  • That Inspector falls back to generic drawing and shows the error.
  • After enough consecutive failures the script editor is disabled.
  • Other panels are unaffected.
  • Recompiling scripts rescans the registry and rebuilds open editors and windows.

Controlled control set

EditorGUILayout provides Label, Space, Toggle, IntField, FloatField, Slider, TextField, Button, HelpBox, and PropertyField, plus BeginHorizontal / EndHorizontal and BeginVertical / EndVertical.

Current boundaries

  • Script CustomPropertyDrawer registration is not exposed.
  • There is no arbitrary ImGui passthrough.
  • Extension points are limited to Inspectors, tool windows, and menu items.

Icon registration boundary

  • Built-in icons are generated from Tools/Icons/icons.manifest.json; editor.icon.* ids stay stable after release, and script extensions reference built-in ids directly.
  • Native modules can register module icons at startup through IconRegistry::Register and call UnregisterModule on unload. Ids must follow editor.icon.<domain>.<name>; never use file paths or transient textures as icon ids.
  • Script extensions do not expose icon registration yet. Add new icons to the manifest on the native side first, then reference them from scripts.

Relationship to native editor code

Built-in panels (Hierarchy, Inspector, Asset Browser, Console, Profiler, Project Settings, and others) are implemented in the C++ editor and register through the same panel and command system. Script extensions are peers of built-in panels for menus and panel management, but scripts only receive the controlled API.

Panels open and close on demand. The quickest way to check whether a panel registered is to open the Window menu and look for it.

Advice for extension authors

  1. Start with a minimal Inspector under Assets/**/Editor/ to verify the registration path.
  2. Access fields through serializedObject; never cache component objects.
  3. For multi-object editing use [CanEditMultipleObjects] and avoid assuming a single target.
  4. When you need a new control type, extend the controlled API first and then update this page.

Next steps

Nullus Engine

Home

中文

English

Clone this wiki locally