Custom Attributes

Spark provides a set of custom attributes for controlling how fields appear in the Spark Editor. These attributes work on fields in SparkDatabaseEntry subclasses and other serialized objects.

Inspector Attributes

[Section]

Groups fields under a collapsible header in the inspector.

[Section("Movement Settings")]
[SerializeField] private float speed = 5f;
[SerializeField] private float jumpHeight = 2f;

[Section("Combat Settings", collapsible: true)]
[SerializeField] private float attackDamage = 10f;

All fields between one [Section] and the next (or the end of the class) are grouped under that section. The collapsible parameter defaults to true.

[DisplayNameTooltip]

Overrides the field label and adds a tooltip.

[DisplayNameTooltip("Walk Speed", "Base movement speed in units per second.")]
[SerializeField] private float speed = 5f;

[ReadOnly]

Makes a field visible but not editable in the inspector. Useful for displaying computed or system-managed values.

[InlineField]

Renders a nested object's fields directly in the parent inspector instead of as a foldout.

[SparkInspector]

Marks a class or field for full Spark inspector customization. This attribute signals the editor to use Spark's custom rendering pipeline for the entire inspector.

[SparkFoldout]

Controls foldout behavior for nested objects.

Field Attributes

[ConditionalField]

Shows or hides a field based on the value of another field on the same object.

The field customSpeed only appears when useCustomSpeed is true. Works with bools, enums, strings, and ints.

[ConditionalMultiField]

Shows a field based on multiple conditions.

Both conditions must be true for the field to show.

[Switch]

Switches field rendering based on another field's value. Similar to conditional fields but designed for switching between different field layouts.

[NestedField]

Renders nested data objects inline with full editing support.

[TagField]

Renders a dropdown with Unity tags.

[CustomFieldUI]

Marks a field for custom UI rendering. The corresponding custom UI handler must be registered in the editor.

Database Attributes

[SparkDatabaseEntrySelector]

Creates a dropdown picker that lets you select any SparkDatabaseEntry from the project.

This opens the entry selector window with search, filtering, and type selection.

[DatabaseEntryDropdown]

Creates a dropdown picker filtered to a specific entry type.

This is more focused than [SparkDatabaseEntrySelector] and only shows entries of the specified type.

[ScriptableObjectDropdown]

Creates a dropdown for selecting ScriptableObject assets of a specific type.

[NestedData]

Marks a list of SparkDatabaseEntryNestedData for inline editing.

The Spark Editor renders these as an editable list with add/remove/reorder controls.

[ShowInEventDropdown]

Exposes a field or event for use in the string-based event dropdown system. This makes it selectable in trigger and rule configurations.

Trigger Attributes

[TriggerRefresh]

Marks a field that should trigger a UI refresh when changed. Used in trigger and requirement type editors.

[HorizontalRuleTriggers]

Adds a visual separator before trigger fields in the editor.

[HorizontalRuleChecks]

Adds a visual separator before requirement check fields in the editor.

Combining Attributes

Attributes can be combined on a single field:

The [Section] groups the field, [DisplayNameTooltip] customizes the label, and [ConditionalField] controls visibility. They all work together.

Usage Guidelines

  • Use [Section] on every entry with more than 5 fields. It keeps the inspector organized.

  • Use [ConditionalField] to hide irrelevant options. Show only what matters for the current configuration.

  • Use [DatabaseEntryDropdown] instead of raw string fields for entry references. It prevents typos and shows available options.

  • Use [ReadOnly] for system-managed fields that users should see but not edit.

  • Use [DisplayNameTooltip] for fields where the variable name alone is not clear enough.

Last updated

Was this helpful?