/// <summary>
        /// 根据给定的 prefab 打开弹出面板,由 AUIpopupOpener 组件调用,或由代码直接调用。
        /// </summary>
        /// <param name="popupPrefab">弹出面板 prefab。</param>
        /// <param name="data">传递给弹出面板的数据。</param>
        /// <param name="overlayColor">遮罩颜色。</param>
        /// <param name="tapToClose">是否可以随意位置点击关闭弹出面板。</param>
        /// <returns>弹出面板。</returns>
        public static AUIPopup OpenPopupPrefab(AUIPopup popupPrefab, object data,
                                               Color overlayColor, bool tapToClose = false)
        {
            Transform pupupXform = PoolManager.Spawn(popupPoolName, popupPrefab.transform);
            var       popup      = pupupXform.GetComponent <AUIPopup>();

            Assert.IsNotNull(popup, "Can not find AUIPopup component.");
            popup.IsPoolItem = true;
            OpenPopup(popup, data, overlayColor, tapToClose);
            return(popup);
        }
        private IEnumerator DeactivatePopup(AUIPopup popup, float delayOfDestroyPopup)
        {
            if (delayOfDestroyPopup > Mathf.Epsilon)
            {
                yield return(new WaitForSeconds(delayOfDestroyPopup));
            }

            if (popup.IsPoolItem)
            {
                PoolManager.Despawn(popup.transform);
            }
            else
            {
                // 在 Unity 2017.2 中,以下两句如果交换顺序会导致 crash
                popup.gameObject.SetActive(false);
                popup.transform.SetParent(popup.Parent, false);
            }

            overlayObj.SetActive(false);
        }
        /// <summary>
        /// 直接打开场景中预置的弹出面板,由 AUIpopupOpener 调用,或由代码直接调用。
        /// </summary>
        /// <param name="popup">场景中预置的弹出面板。</param>
        /// <param name="data">传递给弹出面板的数据。</param>
        /// <param name="overlayColor">遮罩颜色。</param>
        /// <param name="tapToClose">是否可以随意位置点击关闭弹出面板。</param>
        public static void OpenPopup(AUIPopup popup, object data,
                                     Color overlayColor, bool tapToClose = false)
        {
            ActivateOverlay(overlayColor);

            if (tapToClose)
            {
                overlayButton.onClick.AddListener(popup.Close);
            }
            else
            {
                overlayButton.onClick.RemoveAllListeners();
            }

            popup.Parent = popup.transform.parent;
            popup.transform.SetParent(canvasObj.transform, false);
            popup.transform.SetAsLastSibling();
            popup.SetData(data);
            popup.gameObject.SetActive(true);
            popup.OnOpen();
        }
 /// <summary>
 /// 关闭/回收弹出面板,由 Close 按钮调用,或由代码调用,(或由 tap 即关闭的遮罩按钮调用)。
 /// </summary>
 /// <param name="popup"></param>
 public static void ClosePopup(AUIPopup popup, float delayOfDestroyPopup)
 {
     DeactivateOverlay();
     Instance.StartCoroutine(Instance.DeactivatePopup(popup, delayOfDestroyPopup));
 }