コード例 #1
0
        /// <summary>
        /// 创建UIPanel
        /// </summary>
        /// <param name="uiBehaviourName"></param>
        /// <param name="uiLevel"></param>
        /// <param name="initData"></param>
        /// <returns></returns>
        public GameObject CreateUIObj(string uiBehaviourName, int uiLevel, string assetBundleName = null)
        {
            IUIBehaviour ui;

            if (mAllUI.TryGetValue(uiBehaviourName, out ui))
            {
                Log.W("{0}: already exist", uiBehaviourName);
                // 直接返回,不要再调一次Init(),Init()应该只能调用一次
                return(ui.Transform.gameObject);
            }

            ui = QUIBehaviour.Load(uiBehaviourName, assetBundleName);
            mLayerLogic.SetLayer(uiLevel, ui as QUIBehaviour);
            mUIPanelStack.OnCreatUI(uiLevel, ui, uiBehaviourName);
            ReSetLayerIndexDirty();
            ui.Transform.gameObject.name = uiBehaviourName;
            return(ui.Transform.gameObject);
        }
コード例 #2
0
ファイル: QUIManager.cs プロジェクト: tansir23/QFramework
        /// <summary>
        /// 创建UIPanel
        /// </summary>
        /// <param name="uiBehaviourName"></param>
        /// <param name="uiLevel"></param>
        /// <param name="initData"></param>
        /// <returns></returns>
        public GameObject CreateUIObj(string uiBehaviourName, int uiLevel)
        {
            IUIBehaviour ui;

            if (mAllUI.TryGetValue(uiBehaviourName, out ui))
            {
                Log.W("{0}: already exist", uiBehaviourName);
                // 直接返回,不要再调一次Init(),Init()应该只能调用一次
                return(ui.Transform.gameObject);
            }

            ui = QUIBehaviour.Load(uiBehaviourName);

            switch (uiLevel)
            {
            case (int)UILevel.Bg:
                ui.Transform.SetParent(mBgTrans);
                break;

            case (int)UILevel.AnimationUnderPage:
                ui.Transform.SetParent(mAnimationUnderPageTrans);
                break;

            case (int)UILevel.Common:
                ui.Transform.SetParent(mCommonTrans);
                break;

            case (int)UILevel.AnimationOnPage:
                ui.Transform.SetParent(mAnimationOnPageTrans);
                break;

            case (int)UILevel.PopUI:
                ui.Transform.SetParent(mPopUITrans);
                break;

            case (int)UILevel.Const:
                ui.Transform.SetParent(mConstTrans);
                break;

            case (int)UILevel.Toast:
                ui.Transform.SetParent(mToastTrans);
                break;

            case (int)UILevel.Forward:
                ui.Transform.SetParent(mForwardTrans);
                break;
            }



#if NONE_LUA_SUPPORT
            var uiGoRectTrans = ui.Transform as RectTransform;

            uiGoRectTrans.offsetMin          = UnityEngine.Vector2.zero;
            uiGoRectTrans.offsetMax          = UnityEngine.Vector2.zero;
            uiGoRectTrans.anchoredPosition3D = Vector3.zero;
            uiGoRectTrans.anchorMin          = UnityEngine.Vector2.zero;
            uiGoRectTrans.anchorMax          = UnityEngine.Vector2.one;
#endif

            ui.Transform.LocalScaleIdentity();
            ui.Transform.gameObject.name = uiBehaviourName;

            return(ui.Transform.gameObject);
        }