class in UnityEngine.UIElements
/
Inherits from:UIElements.TextElement
/
Implemented in:UnityEngine.UIElementsModule
This is a clickable button.
A Button has a text label element that can respond to pointer and mouse events.
You can add an icon to pair it with the text by assigning a Background (Texture, RenderTexture, Sprite or Vector Image)
to the iconImage API or icon-image UXML property. Please note that by providing an icon image, this will
automatically update the Button's hierarchy to contain an Image and a text label element.
By default, a single left mouse click activates the Button's Clickable property button.
To remove this activator, or add more activators, modify the clickable.activators property.
For details, see ManipulatorActivationFilter.
To bind a Button's text value to the contents of a variable, set the binding-path property in the
UXML file, or the bindingPath property in the C# code, to a string that contains the variable name.
For more information, refer to UXML element Button.
| Property | Description |
|---|---|
| iconOnlyUssClassName | The USS class name for Button elements with an icon only, no text. |
| iconUssClassName | The USS class name for Button elements with an icon. |
| imageUSSClassName | The USS class name of the image element that will be used to display the icon texture. |
| ussClassName | USS class name of elements of this type. |
| Property | Description |
|---|---|
| clickable | Clickable MouseManipulator for this Button. |
| iconImage | The Texture, Sprite, or VectorImage that will represent an icon within a Button element. |
| Constructor | Description |
|---|---|
| Button | Constructs a Button. |
| Event | Description |
|---|---|
| clicked | Callback triggered when the button is clicked. |
| onClick | Obsolete. Use clicked instead. |
| Property | Description |
|---|---|
| selectableUssClassName | USS class name of selectable text elements. |
| ussClassName | USS class name of elements of this type. |
| disabledUssClassName | USS class name of local disabled elements. |
| Property | Description |
|---|---|
| binding | Binding object that will be updated. |
| bindingPath | Path of the target property to be bound. |
| canGrabFocus | Return true if the element can be focused. |