Inspector Button

Adding instance button to the inspector

Inspector Button is not created by us. I got this function around 2019 from somewhere and I can't find the source now. I had made a little bit arrangement on it.

[InspectorButton("Do Stuffs")]
private void InspectorButton()
{
    // do wonderful stuffs
}

[InspectorButton(Expanded = true)]
private void InspectorButtonWithValue(int value)
{
    // do wonderful stuffs with value
}

The usage can be changed by adding parameters.

// enable or disable (default: DisableInPlayMode)
[InspectorButton(Mode = InspectorButtonMode.DisabledInPlayMode)]
[InspectorButton(Mode = InspectorButtonMode.EnabledInPlayMode)]
[InspectorButton(Mode = InspectorButtonMode.AlwaysEnabled)]

// set button name (default: function name)
[InspectorButton(name: "My faviourite name")]

// expanded (default: false), work on function with parameter
[InspectorButton(Expanded = true)]

Last updated