Version 3.3.1.2

Odin has a dedicated attribute overview with examples

InlineButtonAttribute class

Namespace: Sirenix.OdinInspector
Assembly: Sirenix.OdinInspector.Attributes
[DontApplyToListElements]
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.Delegate | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter | AttributeTargets.All, AllowMultiple = true, Inherited = true)]
[Conditional("UNITY_EDITOR")]
public sealed class InlineButtonAttribute : Attribute, _Attribute

The inline button adds a button to the end of a property.

Inheritance
  • System.Object
  • System.Attribute
  • InlineButtonAttribute
Remarks

note

Due to a bug, multiple inline buttons are currently not supported.

Example

The following examples demonstrates how InlineButton can be used.

public class MyComponent : MonoBehaviour
{
	// Adds a button to the end of the A property.
	[InlineButton("MyFunction")]
	public int A;

	// This is example demonstrates how you can change the label of the button.
	// InlineButton also supports refering to string members with $.
	[InlineButton("MyFunction", "Button")]
	public int B;

	private void MyFunction()
	{
		// ...
	}
}

Constructors

InlineButtonAttribute(String, SdfIconType, String)
Draws a button to the right of the property.
public InlineButtonAttribute(string action, SdfIconType icon, string label = null)
Parameters
System.String action

A resolved string that defines the action to perform when the button is clicked, such as an expression or method invocation.

SdfIconType icon

The icon to be shown inside the button.

System.String label

Optional label of the button.

InlineButtonAttribute(String, String)
Draws a button to the right of the property.
public InlineButtonAttribute(string action, string label = null)
Parameters
System.String action

A resolved string that defines the action to perform when the button is clicked, such as an expression or method invocation.

System.String label

Optional label of the button.

Fields

Action
A resolved string that defines the action to perform when the button is clicked, such as an expression or method invocation.
public string Action
ButtonColor
Supports a variety of color formats, including named colors (e.g. "red", "orange", "green", "blue"), hex codes (e.g. "#FF0000" and "#FF0000FF"), and RGBA (e.g. "RGBA(1,1,1,1)") or RGB (e.g. "RGB(1,1,1)"), including Odin attribute expressions (e.g "@this.MyColor"). Here are the available named colors: black, blue, clear, cyan, gray, green, grey, magenta, orange, purple, red, transparent, transparentBlack, transparentWhite, white, yellow, lightblue, lightcyan, lightgray, lightgreen, lightgrey, lightmagenta, lightorange, lightpurple, lightred, lightyellow, darkblue, darkcyan, darkgray, darkgreen, darkgrey, darkmagenta, darkorange, darkpurple, darkred, darkyellow.
public string ButtonColor
Icon
public SdfIconType Icon
IconAlignment
public IconAlignment IconAlignment
Label
Optional label of the button.
public string Label
ShowIf
Optional resolved string that specifies a condition for whether to show the inline button or not.
public string ShowIf
TextColor
Supports a variety of color formats, including named colors (e.g. "red", "orange", "green", "blue"), hex codes (e.g. "#FF0000" and "#FF0000FF"), and RGBA (e.g. "RGBA(1,1,1,1)") or RGB (e.g. "RGB(1,1,1)"), including Odin attribute expressions (e.g "@this.MyColor"). Here are the available named colors: black, blue, clear, cyan, gray, green, grey, magenta, orange, purple, red, transparent, transparentBlack, transparentWhite, white, yellow, lightblue, lightcyan, lightgray, lightgreen, lightgrey, lightmagenta, lightorange, lightpurple, lightred, lightyellow, darkblue, darkcyan, darkgray, darkgreen, darkgrey, darkmagenta, darkorange, darkpurple, darkred, darkyellow.
public string TextColor