Skip to content

Inline Button

[Button] attribute used adding button to field.


Support Types

Any fields


Parameters

Parameter Name Description
Name Name of method.
Label Custom name for button.
Use the @ prefix to indicate, that a texture will be used instead of the name.
Arguments: @{Default Unity Icon Name}, @{Path to texture}
Example: @_Popup, @Assets/...
Width Custom button width.
Style Custom style for button.

Examples

[InlineButton("Function")]
public float value;

public void Function()
{
    //...
}
Note

Make sure that you have added ApexInspector namespace in your script, to get access to all attributes.

using ApexInspector;


Demo

using ApexInspector;
using UnityEngine;

#if UNITY_EDITOR
using UnityEditor;
#endif

public class ExampleComponent : MonoBehaviour
{
    [InlineButton("Function", Label = "@_Popup", Style = "IconButton")]
    public string value;

#if UNITY_EDITOR
    public void Function()
    {
        GenericMenu menu = new GenericMenu();
        menu.AddItem(new GUIContent("Text 1"), false, () => value = "Text 1");
        menu.AddItem(new GUIContent("Text 2"), false, () => value = "Text 2");
        menu.AddItem(new GUIContent("Text 3"), false, () => value = "Text 3");
        menu.ShowAsContext();
    }
#endif
}

Live-demo

Live demo