menu_bookDocumentation
Property Attributes for Editor Inspector
Property Attributes for Editor Inspector
Property attributes customize how fields appear and behave in the s&box editor inspector.
Organization Attributes
| Attribute | Purpose |
|---|---|
| [Group("Name")] | Creates a collapsible group box |
| [ToggleGroup("PropertyName")] | Group with checkbox toggle (bool property holds state) |
| [Title("New Title")] | Changes the displayed property name |
| [Order(100)] | Controls inspector display order |
| [Space] | Adds vertical spacing |
| [Header("Section")] | Adds a bold header above property |
Visibility Attributes
| Attribute | Purpose |
|---|---|
| [Hide] | Hides property from inspector |
| [ShowIf("PropertyName", value)] | Shows when condition matches |
| [HideIf("PropertyName", value)] | Hides when condition matches |
| [ReadOnly] | Display only, cannot edit |
| [Advanced] | Hidden behind "Advanced" dropdown |
Value Constraints
| Attribute | Purpose |
|---|---|
| [Range(0, 100)] | Slider with min/max, optional clamping |
| [Step(10)] | Snap to step increments |
| [Flags] | Display enum as bit flags |
String-Specific
| Attribute | Purpose |
|---|---|
| [Placeholder("Hint text")] | Input placeholder hint |
| [TextArea] | Multi-line text field |
| [FilePath] | File picker with validation |
| [ImageAssetPath] | Image asset picker |
| [MapAssetPath] | Map file picker |
| [FontName] | Font selection dropdown |
| [InputAction] | Input action name picker |
Editor Widgets
| Attribute | Purpose |
|---|---|
| [InlineEditor] | Edit referenced object inline |
| [WideMode] | Wider input field |
| [RequireComponent] | Auto-adds required component |
Validation
CSHARP
[Validate(nameof(IsValid), "Warning message", LogLevel.Warn)]
public int Value { get; set; }
bool IsValid() => Value > 0;Example Usage
CSHARP
public class Weapon : Component
{
[Group("Stats"), Range(0, 100)]
public float Damage { get; set; } = 50;
[Group("Stats"), Range(0.1f, 5f), Title("Fire Rate")]
public float FireRate { get; set; } = 0.2f;
[ToggleGroup("UseRecoil"), Range(0, 10)]
public float RecoilAmount { get; set; } = 2;
[ShowIf("UseRecoil", true)]
public bool UseRecoil { get; set; } = true;
[FilePath, Title("Fire Sound")]
public string FireSound { get; set; }
}
Was this helpful?