Repository navigation
en ui designer
中文 | English | Docs | Repository
The editor is both a consumer and a stress test of the UI system. This page covers the visual editing entry point for UI documents and how project scripts extend the editor interface.
Prerequisites: an editor built with NLS_ENABLE_GAME_UI=ON and an open, saved, runnable scene.
- Right-click in a project directory in the Asset Browser, choose
Create > UI Document, and name itHUD. The editor creates a.uifile and opens UI Designer. Double-click the file to reopen it, or find the panel underWindow > UI Designer. - Select the root in the designer Hierarchy and click
PanelunderControlsto add a child. SetNametoStatusPanel,Layout > Sizeto(320, 100), andStyle > Backgroundto an opaque color. - Confirm that the panel appears in the preview. Click
Saveand check forSaved.Undo/Redorevert or restore design operations;Reloadreads the document from disk. - Create an empty scene object named
HUDand addUICanvasComponentthrough the Inspector's component selector. Drag the.uifile ontoDocumentand setRender ModetoScreen Overlay. - Save the scene and enter Play. A colored panel should appear over the Game View. For text, add Text/Button, fill in
Text, and configure a project font resource. For script control, give elements unique names and look them up through the Canvas API.
The designer exposes names, text, layout mode/size/spacing, and background color. Controls do not yet cover every schema field; some styling and resource configuration still require JSON edits. Successful parsing establishes format validity; fonts, input, and final output still need target-backend runtime checks.
The editor provides a UIDocumentDesigner panel for opening and editing UI documents:
- Opening a document builds the element tree following the
UIDocumentdefinition. - Selecting a node exposes layout, style, text, and control properties for editing.
- The design model and the runtime instance are separate, so design-time changes never mutate a running
UIDocumentInstance. - Saving writes the document JSON; refreshing re-instantiates and increments the generation.
Design-model validation shares the same parsing code as the runtime, so a document that parses in the designer parses at runtime. A parse failure reports a path-qualified diagnostic instead of silently dropping nodes.
The editor's own interface overlay publishes through the same UI runtime: the editor draws into a dedicated overlay that the render side composites, rather than manipulating render resources from business code.
Project editor scripts can register custom Inspectors, tool windows, and menu items.
<Project>/Assets/**/Editor/**/*.cs -> GameScriptsEditor.dll (editor process only)
<Project>/Assets/**/*.cs -> GameScripts.dll (editor and player builds)
Editor scripts may reference Nullus.Editor and derive from ComponentEditor or EditorWindow.
using Nullus;
using Nullus.Editor;
namespace Nullus.GameScriptsEditor;
[CustomEditor(typeof(UICanvasComponent))]
[CanEditMultipleObjects]
public sealed class UiCanvasInspector : ComponentEditor
{
public override void OnInspectorGUI()
{
EditorGUILayout.HelpBox("Drawn from script", MessageType.Info);
EditorGUILayout.PropertyField(serializedObject.FindProperty("document"));
if (EditorGUILayout.Button("Reset pixels per unit"))
{
var pixelsPerUnit = serializedObject.FindProperty("pixelsPerUnit");
if (pixelsPerUnit is not null)
{
pixelsPerUnit.floatValue = 100.0f;
ApplyModifiedProperties();
}
}
}
}using Nullus.Editor;
namespace Nullus.GameScriptsEditor;
public sealed class AssetAuditWindow : EditorWindow
{
[EditorMenuItem("Window/Asset Audit")]
public static void ShowWindow()
{
var window = GetWindow<AssetAuditWindow>() ?? new AssetAuditWindow();
window.Open();
}
public override void OnGUI()
{
EditorGUILayout.Label("Hello from a project editor script");
}
}Custom editors target one of two kinds:
| Target | How it is matched |
|---|---|
| Reflected engine component | Use the generated type carrying NativeTypeName, for example typeof(UICanvasComponent)
|
| Project script component | Use a Nullus.Behaviour subclass, matched by the script's own type name |
All script components share the same native ScriptComponent reflected type, so script component editors match on the script's own full C# type name. One script's editor never affects another script component. Base-class matching across script components is not supported yet.
Scripts cannot write component objects directly. All reads and writes go through serializedObject / SerializedProperty and commit through ApplyModifiedProperties(), which is what makes them share undo, Prefab override, and multi-object editing semantics with the built-in editors.
EditorGUILayout currently provides:
-
Label,Space -
Toggle,IntField,FloatField,Slider -
TextField,Button,HelpBox PropertyField-
BeginHorizontal/EndHorizontal,BeginVertical/EndVertical
- A script editor for the same target 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.
- Menu items may only be attached under the
WindowandToolstop-level menus.
Exceptions thrown by a script or editor are caught: that Inspector falls back to generic drawing with an error message, and after enough consecutive failures the script editor is disabled without affecting other panels. Recompiling scripts rescans the registry and rebuilds open editors and windows.
- v1 does not expose script
CustomPropertyDrawerregistration. - There is no arbitrary ImGui passthrough; the control set is fixed to the controlled API above.
Extending what scripts can do means extending the controlled control set and the registration model first, then updating this page.
- Editor Script Extensions covers the module-level view.
- UI Overview returns to the runtime semantics.
Nullus Engine
中文
- 认识 Nullus
- 安装与快速入门
- 使用编辑器
- 场景与对象
- Prefab 工作流
- 资产与内容管线
- 渲染、材质与光照
- 大场景与资源管理
- 游戏逻辑与脚本
- 用户界面
- 动画与角色
- 物理与交互
- 音频、特效与媒体
- AI 与联网
- 平台、构建与发布
- 扩展与引擎架构
- 调试、性能与质量
- 参考手册
- 示例与发展路线
English
- Getting to Know Nullus
- Install and Quick Start
- Using the Editor
- Scenes and Objects
- Prefab Workflow
- Assets and Content Pipeline
- Rendering, Materials, and Lighting
- Large Scenes and Resource Management
- Gameplay and Scripting
- User Interface
- Animation and Characters
- Physics and Interaction
- Audio, Visual Effects, and Media
- AI and Networking
- Platforms, Builds, and Releases
- Extending the Engine
- Debugging, Performance, and Quality
- Reference
- Examples and Roadmap