/// <summary> /// Add to popuplist /// </summary> /// <param name="pUP"></param> private void PopUpOpenEventHandler(PopUpsController pUP) { if (PopupsList.IndexOf(pUP) == -1) { PopupsList.Add(pUP); } }
private PopUpsController ShowPopup(GameObject popup_prefab, Transform parent, Vector3 position, Action openCallBack, Action closeCallBack) { if (!popup_prefab) { return(null); } PopUpsController pUp = CreateWindow(popup_prefab, parent, position); if (pUp) { pUp.PopUpInit( (g) => { PopUpOpenH(g); if (openCallBack != null) { openCallBack(); } }, (g) => { PopUpCloseH(g); if (closeCallBack != null) { closeCallBack(); } }); pUp.ShowWindow(); } return(pUp); }
private WarningMessController CreateMessage(PopUpsController prefab, string caption, string message, Action yesCallBack, Action cancelCallBack, Action noCallBack) { PopUpsController p = CreateWindow(prefab, transform); WarningMessController pUp = p.GetComponent <WarningMessController>(); pUp.SetControlActivity(false); pUp.PopUpInit(new Action <PopUpsController>(PopUpOpenEventHandler), (g) => { PopUpCloseEventHandler(g); switch (pUp.Answer) { case MessageAnswer.Yes: yesCallBack?.Invoke(); break; case MessageAnswer.Cancel: cancelCallBack?.Invoke(); break; case MessageAnswer.No: noCallBack?.Invoke(); break; } }); pUp.SetMessage(caption, message, yesCallBack != null, cancelCallBack != null, noCallBack != null); p.ShowWindow(); return(pUp); }
public void ShowAlmost(int coins) { PopUpsController pUP = ShowPopUp(AlmostPrefab); AlmostWindowController awc = pUP.GetComponent <AlmostWindowController>(); awc.SetCoins(coins); }
/// <summary> /// Remove from list and destroy /// </summary> /// <param name="pUP"></param> private void PopUpCloseEventHandler(PopUpsController pUP) { if (PopupsList.IndexOf(pUP) != -1) { PopupsList.Remove(pUP); Destroy(pUP.gameObject); } }
protected PopUpsController ShowPopUp(PopUpsController popup_prefab, Transform parent, Action openCallBack, Action closeCallBack) { if (!popup_prefab) { return(null); } PopUpsController pUp = CreateWindow(popup_prefab, parent); if (pUp) { pUp.PopUpInit( (g) => { PopUpOpenEventHandler(g); openCallBack?.Invoke(); }, (g) => { PopUpCloseEventHandler(g); closeCallBack?.Invoke(); }); pUp.ShowWindow(); } return(pUp); }
private WarningMessController CreateMessage(GameObject prefab, string caption, string message, Action yesCallBack, Action cancelCallBack, Action noCallBack) { PopUpsController p = CreateWindow(prefab, popup.transform); WarningMessController pUp = p.GetComponent <WarningMessController>(); pUp.SetControlActivity(false); pUp.PopUpInit(new Action <GameObject>(PopUpOpenH), (g) => { PopUpCloseH(g); switch (pUp.Answer) { case MessageAnswer.Yes: if (yesCallBack != null) { yesCallBack(); } break; case MessageAnswer.Cancel: if (cancelCallBack != null) { cancelCallBack(); } break; case MessageAnswer.No: if (noCallBack != null) { noCallBack(); } break; } }); pUp.SetMessage(caption, message, yesCallBack != null, cancelCallBack != null, noCallBack != null); p.ShowWindow(); return(pUp); }
protected PopUpsController ShowPopUp(PopUpsController popup_prefab, Action openCallBack, Action closeCallBack) { return(ShowPopUp(popup_prefab, transform, openCallBack, closeCallBack)); }
public PopUpsController ShowPopUp(PopUpsController popup_prefab) { PopUpsController pUp = ShowPopUp(popup_prefab, null, null); return(pUp); }
private PopUpsController CreateWindow(PopUpsController prefab, Transform parent, Vector3 position) { GameObject gP = (GameObject)Instantiate(prefab.gameObject, parent); RectTransform mainRT = gP.GetComponent <RectTransform>(); mainRT.SetParent(parent); WindowOpions winOptions = gP.GetComponent <GuiFader_v2>().winOptions; Vector3[] vC = new Vector3[4]; mainRT.GetWorldCorners(vC); RectTransform rt = gP.GetComponent <GuiFader_v2>().guiPanel; Vector3[] vC1 = new Vector3[4]; rt.GetWorldCorners(vC1); float height = (vC1[2] - vC1[0]).y; float width = (vC1[2] - vC1[0]).x; if (winOptions == null) { winOptions = new WindowOpions(); } winOptions.position = position; switch (winOptions.instantiatePosition) { case Position.LeftMiddleOut: rt.position = new Vector3(vC[0].x - width / 2f, (vC[0].y + vC[2].y) / 2f, rt.position.z); break; case Position.RightMiddleOut: rt.position = new Vector3(vC[2].x + width / 2f, (vC[0].y + vC[2].y) / 2f, rt.position.z); break; case Position.MiddleBottomOut: rt.position = new Vector3((vC[0].x + vC[2].x) / 2f, vC[0].y - height / 2f, rt.position.z); break; case Position.MiddleTopOut: rt.position = new Vector3((vC[0].x + vC[2].x) / 2f, vC[2].y + height / 2f, rt.position.z); break; case Position.LeftMiddleIn: rt.position = new Vector3(vC[0].x + width / 2f, (vC[0].y + vC[2].y) / 2f, rt.position.z); break; case Position.RightMiddleIn: rt.position = new Vector3(vC[2].x - width / 2f, (vC[0].y + vC[2].y) / 2f, rt.position.z); break; case Position.MiddleBottomIn: rt.position = new Vector3((vC[0].x + vC[2].x) / 2f, vC[0].y + height / 2f, rt.position.z); break; case Position.MiddleTopIn: rt.position = new Vector3((vC[0].x + vC[2].x) / 2f, vC[2].y - height / 2f, rt.position.z); break; case Position.CustomPosition: rt.position = winOptions.position; break; case Position.AsIs: break; case Position.Center: rt.position = new Vector3((vC[0].x + vC[2].x) / 2f, (vC[0].y + vC[2].y) / 2f, rt.position.z); break; } PopUpsController pUp = gP.GetComponent <PopUpsController>(); if (pUp) { pUp.SetControlActivity(false); } return(pUp); }
public void ShowBoosterEyeBallShop() { PopUpsController mm = ShowPopup(BoosterEyeBallShopWindowPrefab, popup.transform, null); }
public void ShowLifeShop() { PopUpsController mm = ShowPopup(LifeShopWindowPrefab, popup.transform, null); }
public void ShowSettings() { PopUpsController mm = ShowPopup(SettingsWindowPrefab, popup.transform, null); }