Exemplo n.º 1
0
    public bool ClosePopupUI()
    {
        if (_popupStack.Count == 0)
        {
            return(false);
        }

        BaseUIPopup target = _popupStack.Pop();

        GameManager.Resource.Destroy(target.gameObject);
        target = null;

        _order--;
        return(true);
    }
Exemplo n.º 2
0
    public bool ClosePopupUI(BaseUIPopup target, bool findAllPopup = false)
    {
        if (_popupStack.Count == 0)
        {
            return(false);
        }

        if (_popupStack.Peek() == target)
        {
            return(ClosePopupUI());
        }
        else
        {
            if (findAllPopup)
            {
                bool closed = false;
                Stack <BaseUIPopup> tempStack = new Stack <BaseUIPopup>();
                while (_popupStack.Count > 1)
                {
                    tempStack.Push(_popupStack.Pop());

                    BaseUIPopup now = _popupStack.Peek();
                    if (now == target)
                    {
                        closed = ClosePopupUI();
                        break;
                    }
                }
                while (tempStack.Count > 0)
                {
                    BaseUIPopup now = tempStack.Pop();
                    if (closed)
                    {
                        now.GetComponent <Canvas>().sortingOrder--;
                    }

                    _popupStack.Push(now);
                }

                return(closed);
            }
            else
            {
                Debug.Log("Top Popup is not Target.");
                return(false);
            }
        }
    }