示例#1
0
		/// <summary>
		/// 创建UIPanel
		/// </summary>
		/// <param name="uiBehaviourName"></param>
		/// <param name="uiLevel"></param>
		/// <param name="initData"></param>
		/// <returns></returns>
		public GameObject CreateUIObj(string uiBehaviourName, UILevel 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 = UIPanel.Load(uiBehaviourName,assetBundleName);

			mLayerLogic.SetLayer((int)uiLevel,ui as UIPanel);
            mUIPanelStack.OnCreatUI((int)uiLevel,ui,uiBehaviourName);
            ReSetLayerIndexDirty();
            ui.Transform.gameObject.name = uiBehaviourName;

			return ui.Transform.gameObject;
		}
示例#2
0
        public IPanel CreateUI(string uiBehaviourName, UILevel level = UILevel.Common, IUIData uiData = null,
                               string assetBundleName = null)
        {
            IPanel ui;

            if (mAllUI.TryGetValue(uiBehaviourName, out ui))
            {
                return(ui);
            }

            ui = UIPanel.Load(uiBehaviourName, assetBundleName);

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

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

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

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

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

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

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

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

            var uiGoRectTrans = ui.Transform as RectTransform;

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

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

            ui.PanelInfo = new UIPanelInfo
            {
                AssetBundleName = assetBundleName, Level = level, PanelName = uiBehaviourName
            };

            mAllUI.Add(uiBehaviourName, ui);

            ui.Init(uiData);

            return(ui);
        }
示例#3
0
        /// <summary>
        /// 创建UIPanel
        /// </summary>
        /// <param name="uiBehaviourName"></param>
        /// <param name="uiLevel"></param>
        /// <param name="initData"></param>
        /// <returns></returns>
        public GameObject CreateUIObj(string uiBehaviourName, UILevel uiLevel, string assetBundleName = null)
        {
            IUIPanel ui;

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

            ui = UIPanel.Load(uiBehaviourName, assetBundleName);

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

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

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

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

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

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

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

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

            var uiGoRectTrans = ui.Transform as RectTransform;

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

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

            ui.PanelInfo = new UIPanelInfo {
                AssetBundleName = assetBundleName, Level = uiLevel, PanelName = uiBehaviourName
            };
            return(ui.Transform.gameObject);
        }