Namespace: | Sirenix.OdinInspector |
Assembly: | Sirenix.OdinInspector.Attributes |
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public class ButtonAttribute : ShowInInspectorAttribute, _Attribute
Buttons are used on functions, and allows for clickable buttons in the inspector.
The following example shows a component that has an initialize method, that can be called from the inspector.
public class MyComponent : MonoBehaviour
{
[Button]
private void Init()
{
// ...
}
}
The following example show how a Button could be used to test a function.
public class MyBot : MonoBehaviour
{
[Button]
private void Jump()
{
// ...
}
}
The following example show how a Button can named differently than the function it's been attached to.
public class MyComponent : MonoBehaviour
{
[Button("Function")]
private void MyFunction()
{
// ...
}
}
public ButtonAttribute()
public ButtonAttribute(ButtonSizes size)
ButtonSizes | size | The size of the button. |
public ButtonAttribute(ButtonSizes size, ButtonStyle parameterBtnStyle)
ButtonSizes | size | The size of the button. |
ButtonStyle | parameterBtnStyle | Button style for methods with parameters. |
public ButtonAttribute(ButtonStyle parameterBtnStyle)
ButtonStyle | parameterBtnStyle | Button style for methods with parameters. |
public ButtonAttribute(int buttonSize)
System.Int32 | buttonSize | The size of the button. |
public ButtonAttribute(int buttonSize, ButtonStyle parameterBtnStyle)
System.Int32 | buttonSize | The size of the button. |
ButtonStyle | parameterBtnStyle | Button style for methods with parameters. |
public ButtonAttribute(string name)
System.String | name | Custom name for the button. |
public ButtonAttribute(string name, ButtonSizes buttonSize)
System.String | name | Custom name for the button. |
ButtonSizes | buttonSize | Size of the button. |
public ButtonAttribute(string name, ButtonSizes buttonSize, ButtonStyle parameterBtnStyle)
System.String | name | Custom name for the button. |
ButtonSizes | buttonSize | Size of the button. |
ButtonStyle | parameterBtnStyle | Button style for methods with parameters. |
public ButtonAttribute(string name, ButtonStyle parameterBtnStyle)
System.String | name | Custom name for the button. |
ButtonStyle | parameterBtnStyle | Button style for methods with parameters. |
public ButtonAttribute(string name, int buttonSize)
System.String | name | Custom name for the button. |
System.Int32 | buttonSize | Size of the button in pixels. |
public ButtonAttribute(string name, int buttonSize, ButtonStyle parameterBtnStyle)
System.String | name | Custom name for the button. |
System.Int32 | buttonSize | Size of the button in pixels. |
ButtonStyle | parameterBtnStyle | Button style for methods with parameters. |
public int ButtonHeight
public bool Expanded
public string Name
public ButtonStyle Style