Exemplo n.º 1
0
        private IEnumerator _closePopup()
        {
            currentPopupDescriptor = null;
            currentPopup           = null;
            if (HideLastPopup())
            {
                // Should wait here
                yield return(new WaitForSeconds(delayBetweenPopupAnimation));

                objectPool.Pool(popupList[popupList.Count - 1].gameObject);
                popupList.RemoveAt(popupList.Count - 1);

                if (popupList.Count > 0)
                {
                    popupList[popupList.Count - 1].Show();
                }
            }
            else if (popupList.Count > 0)
            {
                // If we're here, that means there was no popup or the last popup was already hidden
                objectPool.Pool(popupList[popupList.Count - 1].gameObject);
                popupList.RemoveAt(popupList.Count - 1);

                if (popupList.Count > 0)
                {
                    popupList[popupList.Count - 1].Show();
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Shows the specified popup, using parameters
        /// </summary>
        /// <param name="popup">Popup.</param>
        /// <param name="parameters">Parameters.</param>
        public void ShowPopup(PopupDescriptor popup, object parameters)
        {
#if UNITY_EDITOR && DEBUG
            Debug.Log("Show popup " + popup + " / current " + currentPopupDescriptor);
#endif
            // If current popup is the same as the current shown one, with the same parameters, do nothing
            if (currentPopupDescriptor != null && currentPopupDescriptor.pooledObjectName == popup.pooledObjectName && (currentPopup != null && CheckParameterEquals(currentPopup.Parameters, parameters)))
            {
#if UNITY_EDITOR && DEBUG
                Debug.Log("Already showing with same parameters, abort !");
#endif
                return;
            }

            // Hide last popup to free the screen
            HideLastPopup();

            // Create the new popup from object pool
            PopupBase popupObject = (objectPool.GetFromPool(popup.pooledObjectName) as GameObject).GetComponent <PopupBase>();
#if UNITY_EDITOR && DEBUG
            Debug.Log("Pooled " + popup.pooledObjectName + " => " + popupObject.name);
#endif
            // ensure new popup is above previous one
            if (currentPopup != null)
            {
                popupObject.Canvas.sortingOrder = currentPopup.Canvas.sortingOrder + 1;
            }
            else
            {
                popupObject.Canvas.sortingOrder = defaultSortingLayer;
            }
            // Initialize the new popup with specified parameters
            popupObject.Init(parameters);

            // Show the new popup
            currentPopupDescriptor = popup;
            currentPopup           = popupObject;
            popupObject.Show();

            // Add it to the list
            popupList.Add(popupObject);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Shows the specified popup.
 /// </summary>
 /// <param name="popup">Popup.</param>
 public static void ShowPopup(PopupDescriptor popup)
 {
     Instance.ShowPopup(popup, null);
 }