123456789101112131415161718192021222324252627282930313233343536 |
- using UnityEngine;
- public class Clickable : MonoBehaviour
- {
- public delegate void ClickAction();
- public event ClickAction OnClicked;
- [HideInInspector]
- public bool Interactable = true;
- private bool once;
- virtual public void DoSomething()
- {
- FadeScreen.Instance.active = false; // interrupt update fading if user want to fast change location
- if (OnClicked != null)
- {
- OnClicked();
- }
- }
- private void OnMouseDown()
- {
- if (!once && Interactable)
- {
- DoSomething();
- once = true;
- }
- }
- private void OnMouseUp()
- {
- once = false;
- }
- }
|