Ejemplo n.º 1
0
    /// <summary>
    /// Sync Show UI Logic
    /// </summary>
    public void Show()
    {
        //1:instance UI
        if (this.gameObject == null && string.IsNullOrEmpty(uiPath) == false)
        {
            GameObject go = null;
            if (PageMgr.delegateSyncLoadUI != null)
            {
                Object o = PageMgr.delegateSyncLoadUI(uiPath);
                go = o != null?GameObject.Instantiate(o) as GameObject : null;
            }
            else
            {
                go = GameObject.Instantiate(Resources.Load(uiPath)) as GameObject;
            }

            //protected.
            if (go == null)
            {
                Debugger.LogError("[UI] Cant sync load your ui prefab.uiPath = " + uiPath);
                return;
            }

            AnchorUIGameObject(go);

            //after instance should awake init.
            Awake(go);

            //mark this ui sync ui
            isAsyncUI = false;
            Transform bgTrans = this.transform.Find("bg");
            if (bgTrans != null)
            {
                bgImg = bgTrans.GetComponent <Image>();
            }
            m_ContentTrans = this.transform.Find("Content");
        }

        //:animation or init when active.
        Active();

        //:refresh ui component.
        Refresh();

        //:popup this node to top if need back.
        PageMgr.PopNode(this);
    }