/// <summary> /// Set UI /// </summary> /// <param name="aData"> Queued Popup data </param> private void ShowUI(QueuedPopUpData aData) { mCurrentCard = aData; // Fill Data in UI UIPopup tPop = _instance.GetPopupGO(); tPop.m_HeadingText.text = aData.HeadingMessage; tPop.m_MessageText.text = aData.DescriptionMessage; tPop.m_WarningText.text = aData.WarningMessage; tPop.m_OKButtonText.text = aData.OkButtonLabel; tPop.m_RightButtonText.text = aData.RightButtonLabel; tPop.m_LeftButtonText.text = aData.LeftButtonLable; buttonCallback = aData.callback; // Button Activation bool tValue = string.IsNullOrEmpty(aData.OkButtonLabel); tPop._OkButton.gameObject.SetActive(!tValue); tPop._RightButton.gameObject.SetActive(tValue); tPop._LeftButton.gameObject.SetActive(tValue); tPop._CrossButton.gameObject.SetActive(aData.CrossAllowed); m_GenericPopup.gameObject.SetActive(true); //Play Popup UI tween animation Utils.PlayAnimation(m_GenericPopup.m_RootGameObject, m_GenericPopup.gameObject.GetComponent <Image>(), true); }
/// <summary> /// Instantiate current popup type /// Set instantiated popup rectransform /// Set popup button listner /// </summary> /// <returns> current popup type</returns> private UIPopup GetPopupGO() { if (m_GenericPopup == null) { GameObject go = Instantiate(m_GenericPopupPrefab); go.transform.SetParent(transform); // root go.transform.SetAsFirstSibling(); go.transform.localScale = Vector3.one; RectTransform trans = go.GetComponent <RectTransform>(); trans.localPosition = Vector3.zero; trans.offsetMax = Vector2.zero; trans.offsetMin = Vector2.zero; m_GenericPopup = go.GetComponent <UIPopup>(); // Set Listner m_GenericPopup._OkButton.onClick.AddListener(() => { if ((bool)_instance.mCurrentCard?.IsAutoClose) { Hide(); } buttonCallback?.Invoke(PopUpButtonCallback.OK); }); m_GenericPopup._LeftButton.onClick.AddListener(() => { if ((bool)_instance.mCurrentCard?.IsAutoClose) { Hide(); } buttonCallback?.Invoke(PopUpButtonCallback.LEFT); }); m_GenericPopup._RightButton.onClick.AddListener(() => { if ((bool)_instance.mCurrentCard?.IsAutoClose) { Hide(); } buttonCallback?.Invoke(PopUpButtonCallback.RIGHT); }); m_GenericPopup._CrossButton.onClick.AddListener(() => { if ((bool)_instance.mCurrentCard?.IsAutoClose) { Hide(); } buttonCallback?.Invoke(PopUpButtonCallback.CROSS); }); } return(m_GenericPopup); }