//--------------------------------------------------------------------------------------------------------------- public void AssignCaller(FlexiblePopUp popup) { if (popup.IsNull()) { this.gameObject.SetActive(false); return; } this.Caller = popup; }
//--------------------------------------------------------------------------------------------------------------- public static FlexiblePopUp Instantiate(string prefabName, Transform parent = null, string path = "", object data = null, float lockTime = DefaultLockTime) { if (path == "") { path = "Prefabs/"; } GameObject prefab = Resources.Load(path + prefabName) as GameObject; if (prefab == null) { Debug.Log("Attempt to Instantiate popup with path " + path + prefabName + ", but Resources.Load returned null."); return(null); } if (parent == null) { parent = Game.Canvas.transform; } FlexiblePopUp result = GameObject.Instantiate(prefab, parent).GetComponent <FlexiblePopUp>(); if (!result.IsNull()) { if (result.Collider == null) { result.Collider = result.GetComponent <Collider2D>(); } } result.LockTime = lockTime; result.TimerLock = true; result.LockTimer = Game.TimerManager.Start(result.LockTime, callback: () => { result.UnlockSelf(); }); if (data != null) { result.Activate(data); } return(result); }