Ejemplo n.º 1
0
    /// <summary>
    /// GuiWrapper切换,有缩放动画
    /// </summary>
    /// <param name="targetID"></param>
    /// <param name="isIn"></param>
    public void SwitchWrapperWithScale(GuiFrameID targetID, bool isIn)
    {
        root.GetComponent <GraphicRaycaster>().enabled = false;
        Object reource = GetGuiResource(targetID);

        if (reource == null)
        {
            MyDebug.LogYellow("Can not load reousce: " + targetID.ToString());
            return;
        }
        GameObject targetWrapper = Object.Instantiate(reource, root.transform) as GameObject;

        if (isIn)
        {
            targetWrapper.transform.DOScale(Vector3.zero, TweenDuration).
            From().
            SetEase(Ease.OutQuint).
            OnComplete(() => TweenComplete(targetWrapper));
        }
        else
        {
            targetWrapper.transform.SetAsFirstSibling();
            GuiFrameWrapper topGui = null;
            if (guiFrameStack.Count > 0)
            {
                topGui = guiFrameStack.Peek();
            }
            if (topGui)
            {
                topGui.transform.DOScale(Vector3.zero, TweenDuration).
                SetEase(Ease.OutQuint).
                OnComplete(() => TweenComplete(targetWrapper));
            }
        }
    }
Ejemplo n.º 2
0
 private void TweenComplete(GameObject targetWrapper)
 {
     if (guiFrameStack.Count > 0)
     {
         GuiFrameWrapper oldGui = guiFrameStack.Pop();
         if (oldGui)
         {
             Object.Destroy(oldGui.gameObject);
         }
     }
     guiFrameStack.Push(targetWrapper.GetComponent <GuiFrameWrapper>());
     root.GetComponent <GraphicRaycaster>().enabled = true;
 }
Ejemplo n.º 3
0
    /// <summary>
    /// GuiWrapper切换,无动画
    /// </summary>
    /// <param name="targetID"></param>
    public void SwitchWrapper(GuiFrameID targetID, bool isAdd = false)
    {
        if (!isAdd)
        {
            if (guiFrameStack.Count > 0)
            {
                GuiFrameWrapper oldGui = guiFrameStack.Pop();
                if (oldGui)
                {
                    Object.Destroy(oldGui.gameObject);
                }
            }
            if (guiFrameStack.Count > 0)
            {
                GuiFrameWrapper oldGui = guiFrameStack.Peek();
                if (oldGui)
                {
                    oldGui.GetComponent <CanvasGroup>().blocksRaycasts = true;
                }
            }
        }
        else
        {
            if (guiFrameStack.Count > 0)
            {
                GuiFrameWrapper oldGui = guiFrameStack.Peek();
                if (oldGui)
                {
                    oldGui.GetComponent <CanvasGroup>().blocksRaycasts = false;
                }
            }
        }

        if (targetID != GuiFrameID.None)
        {
            Object reource = GetGuiResource(targetID);
            if (reource == null)
            {
                MyDebug.LogYellow("Can not load reousce:" + targetID.ToString());
                return;
            }
            GameObject newGui = Object.Instantiate(reource, root.transform) as GameObject;
            guiFrameStack.Push(newGui.GetComponent <GuiFrameWrapper>());
        }
    }