Ecosystem Hub Core Framework (156+) Animated (87) Component Designer (75) Hierarchy Designer (83) Validation Module (39) Inspector Customizer ToolBox Vol. 1 (4)

[Button]

Target: Method | Field | Property Allow Multiple: Yes Zero GC

Renders an interactive, styled execution button in the Unity Inspector that invokes C# methods with custom icons, colors, parameter input panels, and layout sizing.

Unity Inspector Simulated Preview • Spawner.cs
Wave Number

1. Overview & Value Proposition

What it does: Turns regular C# methods into clickable, styled execution buttons right in the Unity Inspector.

The Problem: In standard Unity, there is no native way to test or trigger methods from the Inspector. You typically have to write custom editor scripts or enter Play Mode and wire debug keys.

The Solution: Adding [Button] gives you:

  • 1-Click Execution: Run methods directly in Edit Mode or Play Mode with a single click.
  • Custom Styling: Modify button label, background color, text color, icons, and height.
  • Parameter Support: Automatically renders foldout parameter panels for methods with arguments.
  • Conditional Logic: Supports inline ShowIf and EnableIf to dynamically disable or hide buttons.

2. Quick Start Example

using UnityEngine;
using MaharajaStudio.MSUltimate.Runtime;

public class Spawner : MonoBehaviour
{
    public int currentWave = 3;

    [Button("Spawn Wave", colorHex: "#27AE60", Icon = "d_PlayButton", Height = 32)]
    public void TriggerSpawn()
    {
        Debug.Log("Spawning wave " + currentWave + " of enemies!");
    }

    [Button("Reset Spawner", colorHex: "#E74C3C")]
    public void ResetWave()
    {
        currentWave = 1;
    }
}

3. Customization Options & Properties

Property Type Default Description
Label string null Custom button label (defaults to TitleCase method name).
ColorHex / BackgroundColor string null Hex color code applied to button background (e.g. "#27AE60").
Height int 30 Pixel height of the button element.
Icon string null Unity Editor icon name (e.g. "d_PlayButton", "d_Refresh").
FullWidth bool false Expands button horizontally across the full inspector width.

[EnableIf]

Target: Field | Property | Method Compound Expressions: Yes UI Toolkit Native

Enables user interaction with a serialized field, property, or button only when a specified condition evaluates to true (greying it out otherwise).

Unity Inspector Simulated Preview • CharacterShield.cs
Has Energy Shield
Max Capacity
Overcharge Multiplier 🔒

1. Overview & Value Proposition

What it does: Keeps dependent settings visible so designers know they exist, but locks them interactively in a disabled state until criteria are satisfied.

The Problem: In standard Unity, secondary fields sit wide open even when their parent feature flag is turned off. Game designers adjust phantom values that have no effect, causing confusing bug reports.

The Solution:

  • Prerequisite Enforcement: Visually greys out fields until conditions evaluate to true.
  • Disabled Tooltips: Shows why a field is locked (e.g. DisabledTooltip = "Requires Level 10!").
  • Inline Expressions: Supports compound comparisons like [EnableIf("$playerLevel >= 10 && $isLicensed")].
  • Zero Polling: Directly binds to UI Toolkit visual change events with zero per-frame recalculations.

2. Quick Start Example

using UnityEngine;
using MaharajaStudio.MSUltimate.Runtime;

public class CharacterShield : MonoBehaviour
{
    public bool hasEnergyShield = true;

    // 1. Basic Boolean Toggle with Custom Tooltip
    [EnableIf(nameof(hasEnergyShield), DisabledTooltip = "Enable Energy Shield to edit capacity!")]
    public float maxShieldCapacity = 100f;

    // 2. Compound Inline Expression
    [EnableIf("$hasEnergyShield && $maxShieldCapacity > 50")]
    public float shieldRechargeRate = 12.5f;
}

3. Customization Options & Properties

Property Type Default Description
Condition string *Required* Member name, method name, or compound C# expression (prefixed with $).
DisabledTooltip string null Custom hover tooltip shown when the field is greyed out.
TargetValue object true Target value to compare against when matching enum or integer values.

Core Framework Architecture & Staged Attributes

156+ Attributes Staged in Workspace

All 156+ core attributes, custom serializers, and window systems are organized inside assets/Documentations/MSUltimate/Documentation/attributes/. The two reference attributes above demonstrate the complete documentation standard.