Astra Child

How to connect to a UIButton ui selection state event

Estimated reading: 1 minute 0 views

About UISelectionStates

The UISelectionState defines the states a UISelectable can be in. Their events are always enabled and available to connect to.

The UISelectionStates are:

  • Normal
  • Highlighted
  • Pressed
  • Selected
  • Disabled


To connect to a ui selection state event from code you need to following:

  • Have a reference to the target UIButton
  • The example below shows how to connect to the Pressed ui selection state of a UIButton
using Doozy.Runtime.UIManager;
using Doozy.Runtime.UIManager.Components;
using UnityEngine;

namespace Sandbox
    public class TestClass : MonoBehaviour
        public UIButton MyButton;

        private void OnEnable()
            //Add event listener

        private void OnDisable()
            //Remove event listener

        private void OnPressed()
            //do stuff
}Code language: PHP (php)
Share this Doc
Scroll to Top