Interactive
Shared input, visual states, scale, sounds, and cursor feedback
Overview
Interactive is the base for Evo UI controls such as Button and Switch. It extends Unity’s Selectable with click events, state notifications, graphic effects, state scaling, audio, and custom cursors. Add it on its own when a custom control needs the same feedback.
Usage
Add Interactive to a UI object with a raycast target. Resolve Raycast can supply a Raycast Area when needed.
Configure navigation and interaction events.
Enable the effects you want and assign their target Graphic.
Connect a Styler Object, or use Procedural Shape’s state color mappings, to respond to interaction states.
Customization
Scale
Scale resizes the control for each interaction state and animates the change with Evo Tween. Each state value multiplies the control's resting scale, so 1 keeps it unchanged and 1.05 makes it 5% larger. A control saved at 0.8 or flipped on an axis keeps those proportions.
Duration and Ease set the animation; see Easing. Custom uses the Curve below it. The animation ignores Time.timeScale, and a state change mid-animation continues from the current size. Target scales another Transform, such as a child visual; leave it empty to scale the control itself.
Graphic Effects
Ripple, Spotlight, and Border Glow each have their own settings object and target Graphic. Start with one effect, then adjust its color, timing, and coverage on the control itself. Turn on Ignore Graphic Alpha to keep an effect visible on a translucent or transparent background.
Audio and Cursors
Style Provider selects custom sound clips or Styler mappings. With Styler, Use Default Preset follows the project's default preset; turn it off to assign another one. Cursor States chooses which states override the system cursor; each state has its own texture and hotspot. Call RefreshCursor() after changing cursor settings while a state is active.
Interaction States
Styler maps Disabled, Normal, Highlighted, Pressed, and Selected to visual feedback. A visual state alone does not disable input; turn off Interactable when the control should stop responding.
Public API
Use Interactive in the Evo.UI namespace.
Properties
| Name | Type | Description |
|---|---|---|
InteractionState | InteractionState | Current visual state. |
TransitionDuration | float | Duration used by interaction color transitions. |
Fields
| Name | Type | Description |
|---|---|---|
ripple | Ripple.Settings | Ripple configuration, including enabled and targetGraphic. |
spotlight | Spotlight.Settings | Spotlight configuration. |
borderGlow | BorderGlow.Settings | Border glow configuration. |
scaleEffect | Interactive.ScaleEffect | Scale configuration, including enabled, target, and the state values. |
styleProvider | StyleProvider | Resolves custom or Styler audio mappings. |
useDefaultStylerPreset | bool | Locks the preset to the current default Styler Preset when using Styler. |
soundEffects | bool | Enables interaction sounds. |
cursorStates | CursorStates | States allowed to override the cursor. |
Methods
| Name | Parameters | Description |
|---|---|---|
SetState() | InteractionState state, bool instant = false | Changes the visual state; instant skips its transition. |
SetInteractable() | bool value | Changes input availability and refreshes the state. |
RefreshCursor() | None | Reapplies the cursor for the current state. |
Events
| Name | Type | Description |
|---|---|---|
onClick | UnityEvent | Invoked by a valid click or submit. |
onDoubleClick | UnityEvent | Used by Button’s double-click handling. |
onPointerDown | UnityEvent | Pointer pressed. |
onPointerUp | UnityEvent | Pointer released. |
onPointerEnter | UnityEvent | Pointer entered. |
onPointerExit | UnityEvent | Pointer exited. |
onSelect | UnityEvent | Selected by the EventSystem. |
onDeselect | UnityEvent | Deselected by the EventSystem. |
onSubmit | UnityEvent | Submit input received. |
OnStateChanged | Action<InteractionState> | C# event carrying the new interaction state. |
Scale Effect
Interactive.ScaleEffect exposes enabled, target, duration, ease, curve, and the disabled, normal, highlighted, pressed, and selected values. ease uses Ease from Evo.Tween. GetMultiplier() returns the value for a state, and Clear() stops the animation and restores the resting scale. Changes made from code apply on the next state change.
Example
using UnityEngine;
using Evo.UI;
public class InteractiveExample : MonoBehaviour
{
[SerializeField] private Interactive target;
private void Start()
{
target.ripple.enabled = true;
target.spotlight.enabled = true;
target.scaleEffect.enabled = true;
target.scaleEffect.pressed = 0.9f;
target.SetInteractable(true);
target.onClick.AddListener(() => Debug.Log("Activated"));
}
}