Ejemplo n.º 1
0
        /// <summary>
        /// UI初始化
        /// </summary>
        public void InitUI()
        {
            if (mUIPrefab != null)
            {
                //spawn
                mUIGameObject = GameObject.Instantiate(mUIPrefab, mGateway.UIKit_UIRoot_Trans);
                //改名
                mUIGameObject.Name(mUIGameObject.name.Replace("(Clone)", ""));

                mUIEntity = mUIGameObject.GetComponentOrAdd <UIEntity>();

                //处理gameobject的recttransform
                var trans = mUIGameObject.GetComponent <RectTransform>();
                if (trans != null)
                {
                    trans.anchorMax          = Vector2.one;
                    trans.anchorMin          = Vector2.zero;
                    trans.localScale         = Vector3.one;
                    trans.anchoredPosition3D = Vector3.zero;
                }

                mGateway.UIKit_LayerMgr.OnUIOpen(out int layerIndex, mUIEntity.IsFullScreenUI, mUIEntity.DontPauseWhenHide, mUIEntity);

                var canvas = mUIGameObject.GetComponent <Canvas>();
                if (canvas != null)
                {
                    canvas.overrideSorting = true;

                    //层级关系
                    canvas.sortingOrder = layerIndex;
                }
                mUICanvas = canvas;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 将某个UI置顶
        /// </summary>
        /// <param name="uientity"></param>
        public void SetUILayerTop(UIEntity uiEntity)
        {
            if (uiEntity == mUIPool[mUIPool.Count - 1])
            {
                return;
            }
            int cur_max_layer_index = mUIPool[mUIPool.Count - 1].LayerIndex;

            for (var i = mUIPool.Count - 1; i >= 0; i--)
            {
                if (mUIPool[i] != uiEntity)
                {
                    //把这个UI上面的UI层级依次减10
                    mUIPool[i].SetLayer(mUIPool[i].LayerIndex - 10);
                }
                else
                {
                    uiEntity.SetLayer(cur_max_layer_index);
                    //得把这个UI在list中放在最后面
                    var temp = mUIPool[mUIPool.Count - 1];
                    mUIPool[mUIPool.Count - 1] = mUIPool[i];
                    mUIPool[i] = temp;
                    break;
                }
            }
        }
Ejemplo n.º 3
0
        private UIEntity mCur_Active_FullScreenUI;               //当前活动状态的全屏界面


        /// <summary>
        /// 当新的UI被打开
        /// </summary>
        /// <param name="IsFullScreen">是否为全屏UI</param>
        /// <param name="DontPauseWhenHide">在全屏UI隐藏时,不要暂停</param>
        /// <param name="uiLayer">UI本体Layer序列</param>
        public void OnUIOpen(out int uiLayer, bool IsFullScreen, bool DontPauseWhenHide, UIEntity _Entity)
        {
            //先存入UI
            mUIPool.Add(_Entity);
            ////最大UI层级数 + 10 (也就是一个UI占用的数量)
            //mCurMaxLayer = mCurMaxLayer + 10;]
            mCurMaxLayer = mUIPool.Count * 10 + 1;

            uiLayer = mCurMaxLayer;

            //全屏UI处理
            if (IsFullScreen)
            {
                //记录
                mFullScreen_GameObject_List.Add(_Entity);
                if (mCur_Active_FullScreenUI != null)
                {
                    //顶替流程

                    //从视口中移走先
                    var rect_trans = mCur_Active_FullScreenUI.gameObject.GetComponent <RectTransform>();
                    rect_trans.anchoredPosition = new Vector2(rect_trans.anchoredPosition.x, rect_trans.anchoredPosition.y + (mGateway.UIKit_UIRoot_RectTrans.rect.size.y * (mFullScreen_GameObject_List.Count) + 1) + 100);

                    if (!mCur_Active_FullScreenUI.DontPauseWhenHide)
                    {
                        mCur_Active_FullScreenUI.gameObject.Hide(); //隐藏之后,这里的运算会停掉,省资源
                    }
                }

                mCur_Active_FullScreenUI = _Entity;
            }
        }
Ejemplo n.º 4
0
        public void OnUIClose(UIItem ui_item)
        {
            if (ui_item.LayerIndex == mCurMaxLayer)
            {
                //将被关掉的是最顶级的UI;
                mCurMaxLayer -= 10;
            }
            var entity = ui_item.GetUIEntity();

            if (entity.IsFullScreenUI)
            {
                mFullScreen_GameObject_List.Remove(entity);
                //全屏
                if (mCur_Active_FullScreenUI == entity)
                {
                    //将被关掉的就是最顶级UI,找到上一个UI并放出来
                    if (mFullScreen_GameObject_List.Count > 0)
                    {
                        mCur_Active_FullScreenUI = mFullScreen_GameObject_List[mFullScreen_GameObject_List.Count - 1];
                        //放出来
                        mCur_Active_FullScreenUI.gameObject.Show();
                        var rect_trans = mCur_Active_FullScreenUI.gameObject.GetComponent <RectTransform>();
                        rect_trans.anchoredPosition3D = Vector3.zero;
                    }
                    else
                    {
                        mCur_Active_FullScreenUI = null;
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public void OnUIClose(UIItem ui_item)
        {
            //if(ui_item.LayerIndex == mCurMaxLayer)
            //{
            //    //将被关掉的是最顶级的UI;
            //    mCurMaxLayer -= 10;
            //}
            var entity = ui_item.GetUIEntity();

            for (var i = mUIPool.Count - 1; i >= 0; i--)
            {
                if (mUIPool[i] != entity)
                {
                    //被关掉的不是最顶层的UI
                    //把这个UI上面的UI层级依次减10
                    mUIPool[i].SetLayer(mUIPool[i].LayerIndex - 10);
                }
                else
                {
                    mUIPool.RemoveAt(i);
                    break;
                }
            }

            //var entity = ui_item.GetUIEntity();
            if (entity.IsFullScreenUI)
            {
                mFullScreen_GameObject_List.Remove(entity);
                //全屏
                if (mCur_Active_FullScreenUI == entity)
                {
                    //将被关掉的就是最顶级UI,找到上一个UI并放出来
                    if (mFullScreen_GameObject_List.Count > 0)
                    {
                        mCur_Active_FullScreenUI = mFullScreen_GameObject_List[mFullScreen_GameObject_List.Count - 1];
                        //放出来
                        mCur_Active_FullScreenUI.gameObject.Show();
                        var rect_trans = mCur_Active_FullScreenUI.gameObject.GetComponent <RectTransform>();
                        rect_trans.anchoredPosition3D = Vector3.zero;
                    }
                    else
                    {
                        mCur_Active_FullScreenUI = null;
                    }
                }
            }
        }
Ejemplo n.º 6
0
        protected override sealed void Awake()
        {
            //编辑器里需要直接使用Public的变量作为配置,所有不能做限制。但是要防止它在运行时被改变,所有在初始化时把它转成私有的,接下来都用私有里面的数值
            mEnableUpdate     = EnableUpdate;
            mEnableLateUpdate = EnableLateUpdate;
            mUpdateOrder      = UpdateOrder;
            mLateUpdateOrder  = LateUpdateOrder;
            if (mEnableUpdate)
            {
                TimeMachine.I.AddUpdate(Self_Update, mUpdateOrder);
            }
            if (mEnableLateUpdate)
            {
                TimeMachine.I.AddLateUpdate(Self_LateUpdate, mLateUpdateOrder);
            }

            mUIEntity = gameObject.GetComponent <UIEntity>();

            XAwake();
        }
Ejemplo n.º 7
0
 public void CloseUI() //调用这里就直接关了,要传参数的话,传完了再调用
 {
     //告诉遮罩管理器,如果有遮罩的话
     if (mUseMask)
     {
         mGateway.UIKit_MaskMgr.RemoveMask(this);
     }
     //告诉层级管理器
     mGateway.UIKit_LayerMgr.OnUIClose(this);
     //手起刀落
     GameObject.Destroy(mUIEntity.gameObject);
     //通知资源管理器,可以回收了
     VFSMgr.I.RemoveUse(mUIPath);
     //打扫
     mUIEntity     = null;
     mUIPrefab     = null;
     mGateway      = null;
     mUIGameObject = null;
     mUICanvas     = null;
 }
Ejemplo n.º 8
0
 public void AddChild(UIEntity child)
 {
     m_childs.Add(child);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// 登记Child
 /// </summary>
 public void AddChild(UIEntity child)
 {
     mUIEntity.AddChild(child);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// 置顶UI
 /// </summary>
 public void SetUILayerTop(UIEntity entity)
 {
     m_UILayerMgr.SetUILayerTop(entity);
 }