Button Attribute

Buttons are used on functions, and allows for clickable buttons in the inspector.

public string ButtonName = "Dynamic button name";

public bool Toggle;

[Button("$ButtonName")]
private void DefaultSizedButton()
{
    this.Toggle = !this.Toggle;
}

[Button("@\"Expression label: \" + DateTime.Now.ToString(\"HH:mm:ss\")")]
public void ExpressionLabel()
{
    this.Toggle = !this.Toggle;
}

[Button("Name of button")]
private void NamedButton()
{
    this.Toggle = !this.Toggle;
}

[Button(ButtonSizes.Small)]
private void SmallButton()
{
    this.Toggle = !this.Toggle;
}

[Button(ButtonSizes.Medium)]
private void MediumSizedButton()
{
    this.Toggle = !this.Toggle;
}

[DisableIf("Toggle")]
[HorizontalGroup("Split", 0.5f)]
[Button(ButtonSizes.Large), GUIColor(0.4f, 0.8f, 1)]
private void FanzyButton1()
{
    this.Toggle = !this.Toggle;
}

[HideIf("Toggle")]
[VerticalGroup("Split/right")]
[Button(ButtonSizes.Large), GUIColor(0, 1, 0)]
private void FanzyButton2()
{
    this.Toggle = !this.Toggle;
}

[ShowIf("Toggle")]
[VerticalGroup("Split/right")]
[Button(ButtonSizes.Large), GUIColor(1, 0.2f, 0)]
private void FanzyButton3()
{
    this.Toggle = !this.Toggle;
}

[Button(ButtonSizes.Gigantic)]
private void GiganticButton()
{
    this.Toggle = !this.Toggle;
}

[Button(90)]
private void CustomSizedButton()
{
    this.Toggle = !this.Toggle;
}

[Button(Icon = SdfIconType.Dice1Fill, IconAlignment = IconAlignment.LeftOfText)]
private void IconButton01()
{
    this.Toggle = !this.Toggle;
}

[Button(Icon = SdfIconType.Dice2Fill, IconAlignment = IconAlignment.LeftOfText)]
private void IconButton02()
{
    this.Toggle = !this.Toggle;
}

[Button]
private void Default(float a, float b, GameObject c)
{
}

[Button]
private void Default(float t, float b, float[] c)
{
}

[Button(ButtonSizes.Medium, ButtonStyle.FoldoutButton)]
private int FoldoutButton(int a = 2, int b = 2)
{
    return a + b;
}

[Button(ButtonSizes.Medium, ButtonStyle.FoldoutButton)]
private void FoldoutButton(int a, int b, ref int result)
{
    result = a + b;
}

[Button(ButtonStyle.Box)]
private void Full(float a, float b, out float c)
{
    c = a + b;
}

[Button(ButtonSizes.Large, ButtonStyle.Box)]
private void Full(int a, float b, out float c)
{
    c = a + b;
}

[Button(ButtonStyle.CompactBox, Expanded = true)]
private void CompactExpanded(float a, float b, GameObject c)
{
}

[Button(ButtonSizes.Medium, ButtonStyle.Box, Expanded = true)]
private void FullExpanded(float a, float b)
{
}

[Button(SdfIconType.Dice1Fill, IconAlignment.LeftOfText)]
private void IconButtonLeftOfText() {}

[Button(SdfIconType.Dice2Fill, IconAlignment.RightOfText)]
private void IconButtonRightOfText() {}

[Button(SdfIconType.Dice3Fill, IconAlignment.LeftEdge)]
private void IconButtonLeftEdge() {}

[Button(SdfIconType.Dice4Fill, IconAlignment.RightEdge)]
private void IconButtonRightEdge() {}

[Button(SdfIconType.Dice5Fill, IconAlignment.RightEdge, Stretch = false)]
private void DontStretch() {}

[Button(SdfIconType.Dice5Fill, IconAlignment.RightEdge, Stretch = false, ButtonAlignment = 1f)]
private void DontStretchAndAlign() {}

public IconButtonGroupExamples iconButtonGroupExamples;

[ButtonGroup]
private void A()
{
}

[ButtonGroup]
private void B()
{
}

[ButtonGroup]
private void C()
{
}

[ButtonGroup]
private void D()
{
}

[Button(ButtonSizes.Large)]
[ButtonGroup("My Button Group")]
private void E()
{
}

[GUIColor(0, 1, 0)]
[ButtonGroup("My Button Group")]
private void F()
{
}

[Serializable, HideLabel]
public struct IconButtonGroupExamples
{
    [ButtonGroup(ButtonHeight = 25), Button(SdfIconType.ArrowsMove, "")]
    void ArrowsMove() { }

    [ButtonGroup, Button(SdfIconType.Crop, "")]
    void Crop() { }

    [ButtonGroup, Button(SdfIconType.TextLeft, "")]
    void TextLeft() { }

    [ButtonGroup, Button(SdfIconType.TextRight, "")]
    void TextRight() { }

    [ButtonGroup, Button(SdfIconType.TextParagraph, "")]
    void TextParagraph() { }

    [ButtonGroup, Button(SdfIconType.Textarea, "")]
    void Textarea() { }
}