예제 #1
0
    private static void LoadView(int id, Action <UIBaseView> callback, bool pushStack, params object[] args)
    {
        var canvas = canvasGo;

        if (id == preLoadId || id == 0)
        {
            return;
        }

        if (id == -1)
        {
            ShowMainViews(callback);
            return;
        }

        UIViewDeploy viewDeploy = Deploy.GetDeploy <UIViewDeploy>(1);

        if (viewDeploy)
        {
            ViewNode preViewNode = viewNodeStack.Count > 0 ? viewNodeStack.Peek() : null;
            ViewNode curViewNode = new ViewNode(null, viewDeploy, args);
            LoadRawView(viewDeploy, uiBaseView =>
            {
                if (viewDeploy.uiViewLayer == UIViewLayer.View)
                {
                    HidePreViews();
                }
                else
                {
                    viewNodeStack.Peek().ShowEffects(false);
                }

                uiBaseView.args    = args;
                curViewNode.uiView = uiBaseView;
                curViewNode.SetAsLastSibling(true);

                if (pushStack)
                {
                    viewNodeStack.Push(curViewNode);
                }

                if (curViewNode.CheckInViewLayer(UIViewLayer.View))
                {
                    ShowWidgetInToolbarLayer(curViewNode);
                }
                else
                {
                    ShowWidgetInToolbarLayer(preViewNode);
                }

                if (callback != null)
                {
                    callback(uiBaseView);
                }

                preLoadId = 0;
            });
        }
        else
        {
            Debug.LogErrorFormat("UIViewDeploy[id={0}] not found!", id);
        }
    }