Button
Buttons with text, icons, adaptive sizing, and interaction feedback
Overview
Button combines a text label and an optional icon with Interactive feedback. Use it for menu actions, toolbar items, and any control that needs a click or submit event.
Usage
Create a Button from Evo UI’s Create menu. The prefab includes the content and layout references.
Set Text and Icon, then choose which parts to display.
Add your action to On Click. Keyboard and controller submit use the same action.
Enable Allow Double Click only when you need a separate double-click response.
Customization
Content and Layout
Dynamic Scale sizes the button around its content. Turn it off when a parent layout group owns the button’s size. Padding, Spacing, and Reverse Arrangement control the icon and text layout.
Content controls edit the referenced Image, text, and layout components directly. The label can use any text provider.
Effects
Ripple, spotlight, border glow, sound, and cursor feedback are provided through Interactive. All of these can be enabled, disabled, or customized through the Inspector or the public API.
Double Clicks
Allow Double Click adds a response to two left clicks within Double Click Duration. Each click still invokes On Click; the second also invokes On Double Click. Keep this in mind when assigning actions to both events. Timing uses unscaled time.
Public API
Use Button in the Evo.UI namespace.
Properties
| Name | Type | Description |
|---|---|---|
Text | string | Displayed label. Setting it shows the label; an empty or blank value hides it. |
Icon | Sprite | Sprite displayed beside the label. Setting it shows the icon; null hides it. |
EnableText | bool | Shows or hides the label. |
EnableIcon | bool | Shows or hides the icon. |
TextSize | float | Label font size, clamped to zero or greater. |
IconSize | float | Preferred icon width and height, clamped to zero or greater. |
DynamicScale | bool | Lets the content determine the button size. |
ReverseArrangement | bool | Reverses the icon and text order. |
Spacing | int | Space between the icon and label. |
Padding | RectOffset | Padding applied to the content layout. |
AllowDoubleClick | bool | Enables double-click detection. |
DoubleClickDuration | float | Time window for the second click, clamped to 0.1–1 seconds. |
Fields
| Name | Type | Description |
|---|---|---|
imageObject | UnityEngine.UI.Image | Image used for the icon. |
textObject | Graphic | Text component used for the label, from any text provider. |
Inherited API
onClick, onDoubleClick, SetInteractable(bool), and SetState(InteractionState, bool) come from Interactive.
Example
using UnityEngine;
using Evo.UI;
public class ButtonExample : MonoBehaviour
{
[SerializeField] private Button target;
[SerializeField] private Sprite playIcon;
private void Start()
{
target.Text = "Play";
target.Icon = playIcon; // Hidden when playIcon is null.
target.Padding = new RectOffset(24, 24, 12, 12);
target.onClick.AddListener(Play);
}
private void Play()
{
target.Text = "Loading...";
target.SetInteractable(false); // Prevent another click while loading.
Debug.Log("Start loading the game here.");
}
private void OnDestroy()
{
if (target != null)
target.onClick.RemoveListener(Play);
}
}