using System; using System.Diagnostics; using SUISS.Core; using SUISS.Scheduling; using UnityEngine; namespace SUISSEngine { public class Clickable : MonoBehaviour { public static Clickable Instance(GameObject target) { if (target == null) { string arg = string.Empty; try { arg = target.name; } catch (Exception) { } UnityEngine.Debug.LogError(string.Format("Clickable.Instance called on null GameObject ({0}).", arg)); target = new GameObject(); SingletonMonobehaviour.Instance.ExecuteNextFrame(target, delegate() { UnityEngine.Object.Destroy(target); }); } Clickable clickable = target.GetComponent(); if (clickable == null) { clickable = target.AddComponent(); } return clickable; } public static Clickable Instance(Component target) { return Clickable.Instance(target.gameObject); } //[DebuggerBrowsable(DebuggerBrowsableState.Never)] public event Clickable.ClickAction OnClickEvent; public void OnClick(GameObject target) { if (this.OnClickEvent != null) { this.OnClickEvent(target); } } public delegate void ClickAction(GameObject target); } }