コード例 #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));
            }
        }
    }
コード例 #2
0
    /// <summary>
    /// 获取资源实例
    /// </summary>
    /// <param name="id">GuiFrameID</param>
    /// <returns>资源实例</returns>
    public Object GetGuiResource(GuiFrameID id)
    {
        Object resouce = null;

        if (!frameDict.TryGetValue(id, out resouce))
        {
            resouce = Resources.Load(frameAddressDict[id]);
            frameDict.Add(id, resouce);
        }
        return(resouce);
    }
コード例 #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>());
        }
    }