editor-field-creation

Implement IFieldEditor interfaces for runtime reflection-based script property editing.

13|2|Updated Jul 17, 2023
One-click install
npx skills add https://github.com/kateusz/GameEngine --skill editor-field-creation
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: editor-field-creation
Source: https://github.com/kateusz/GameEngine/tree/main/.claude/skills/editor-field-creation
Command: npx skills add https://github.com/kateusz/GameEngine --skill editor-field-creation

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill guides developers in extending the editor's script inspector to support custom data types. It details how to implement the IFieldEditor interface for runtime polymorphic rendering of script properties discovered via reflection, handling boxing/unboxing patterns, and registering new editors with the FieldEditorRegistry.

Core Features & Use Cases

  • IFieldEditor Implementation: Create custom field editors for new types (e.g., Quaternion, Color, custom structs).
  • Reflection-Based Editing: Understand how the script inspector uses IFieldEditor to render arbitrary types at runtime.
  • Boxing/Unboxing Patterns: Correctly handle object boxing and unboxing for value types.
  • FieldEditorRegistry: Register custom field editors to make them discoverable by the script inspector.
  • Use Case: If game scripts use a custom Color struct, this Skill enables you to create a ColorFieldEditor that renders an intuitive color picker in the script inspector, allowing designers to easily adjust script-defined colors.

Quick Start

Show me how to create a new IFieldEditor for a custom Color struct, including its Draw method and registration in FieldEditorRegistry.

Frequently Asked Questions about editor-field-creation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create custom field editors for script properties in the inspector?

Implement the `IFieldEditor` interface to create custom field editors for arbitrary script property types. The interface requires a `Draw` method that renders UI and returns a boolean indicating whether the value changed, plus an out parameter delivering the updated boxed value. Register your editor with `FieldEditorRegistry` to make it discoverable by the script inspector.

What's the best way to handle boxing and unboxing when editing value types at runtime?

Boxing and unboxing patterns are central to `IFieldEditor` implementation. Your `Draw` method receives a boxed object parameter, unboxes it to the target type for editing, and returns the modified value boxed again via the out parameter. This polymorphic approach enables the script inspector to render any type discovered via reflection without compile-time knowledge.

Can I extend the script inspector to support custom structs like Quaternion or Color?

Yes. Create a custom `IFieldEditor` for your struct type—for example, a `ColorFieldEditor` that renders an intuitive color picker. Handle boxing and unboxing of your struct, then register the editor in `FieldEditorRegistry` so `UIPropertyRenderer.DrawPropertyField` uses it for runtime property rendering in the script inspector.

How does reflection-based property rendering work in the script inspector?

The script inspector uses reflection to discover script properties at runtime, then queries `FieldEditorRegistry` for a matching `IFieldEditor`. The registry returns the appropriate editor, which implements a `Draw` method to render and edit each property polymorphically, handling any type without prior compilation.

Do I need to manually register field editors or can they be discovered automatically?

You must register custom field editors with `FieldEditorRegistry` for the script inspector to discover them. Registration makes your editor available to `UIPropertyRenderer.DrawPropertyField`, enabling the inspector to render and edit your custom types at runtime.