π€ClickableUIElement
Simple version of Button.cs
API
public UnityEvent onPointerDown;
public UnityEvent onPointerUp;
/// <summary>
/// If true - ignore UI element interactions, and if false don't
/// </summary>
public virtual bool Lock;
/// <summary>
/// You can call this method to trigger btn click manualy<br>
/// But it will be handled automaticaly by player interactions</br>
/// </summary>
public void OnPointerDown(PointerEventData eventData);
/// <summary>
/// You can call this method to simulate touch up logic manualy<br>
/// But it will be handled automaticaly by player interactions</br>
/// </summary>
public void OnPointerUp(PointerEventData eventData);How to use
Add this script with Image to object under canvas. You can setup onPointerDown/Up events in the inspector or subscribe+unsubscribe to them runtime in code
If you want to change color in Lock states -> use ColoredClickableUIElement instead (has the same logic, it inherited and has two colors for locked and unlocked states.
Last updated