Beispiel #1
0
        public static void RegisterUILayer(WndLayerDef _nLayerDef, USpeedUILayer _nLayer)
        {
            if (_nLayerDef == WndLayerDef.WND_LAYER_MAX || _nLayerDef == WndLayerDef.WND_LAYER_NONE)
            {
                return;
            }

            if (instance.m_DicLayer.ContainsKey(_nLayerDef))
            {
                return;
            }

            instance.m_DicLayer.Add(_nLayerDef, _nLayer);

            //重新调整canvas的Sorting信息
            _nLayer.LayerCanvas.overrideSorting = true;

            //调整SortingLayer,目前都统一用一个Layer,layer多的话会影响渲染效率
            _nLayer.LayerCanvas.sortingLayerName = CalculateLayerName(_nLayerDef);
            //调整SortingOrder
            _nLayer.LayerCanvas.sortingOrder = CheckSortingOrderRange(CalculateLayerOrder(_nLayerDef));

            //计算Layer的Z轴坐标 layerDef越大,越靠近相机
            Vector3 tmpPos = _nLayer.GetTransform.localPosition;

            tmpPos.z = ((int)WndLayerDef.WND_LAYER_MAX - (int)_nLayerDef) * LayerZAxisDistance;
            _nLayer.GetTransform.localPosition = tmpPos;

            instance.RegisterFailedElementAgain();
        }
Beispiel #2
0
        protected override void PostSetVisible(bool _bVisible)
        {
            if (m_wndView == null)
            {
                return;
            }

            if (_bVisible)
            {
                //有全屏窗口显示中并当前WND_LAYER_POPUP01类型窗口需要显示时,将其提升到WND_LAYER_POPUP02层进行显示
                if (GetLayer() == WndLayerDef.WND_LAYER_POPUP01)
                {
                    UISystem.Instance.SetWndRenderAfterTheFillLayer(m_wndView, WndLayerDef.WND_LAYER_POPUP02);
                }
                //Popup类型显示时顶置
                if ((GetLayer() == WndLayerDef.WND_LAYER_POPUP01 || GetLayer() == WndLayerDef.WND_LAYER_POPUP02))
                {
                    UISystem.Instance.SetMutexWndVisbleAlone(this.m_wndView, WndLayerDef.WND_LAYER_POPUP01, WndLayerDef.WND_LAYER_FILL, WndLayerDef.WND_LAYER_POPUP02);

                    if (m_wndView.GetTransform() != null)
                    {
                        m_wndView.GetTransform().SetAsLastSibling();

                        //System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
                        //StringBuilder sb = new StringBuilder();
                        //watch.Start();

                        //重新算该层级下所有界面的层级数
                        USpeedUILayer layer = USpeedUILayerManager.GetUILayer(GetLayer());
                        if (layer != null)
                        {
                            RectTransform LayerTrans = layer.GetRectTransform;
                            if (LayerTrans != null)
                            {
                                int count = LayerTrans.childCount;
                                for (int i = 0; i < count; ++i)
                                {
                                    USpeedUILayerElement element = LayerTrans.GetChild(i).GetComponent <USpeedUILayerElement>();
                                    if (element != null)
                                    {
                                        LayerTrans.GetChild(i).GetComponent <USpeedUILayerElement>().SetSortingOrder();
                                    }
                                }
                            }
                        }
                    }

                    //watch.Stop();
                    //sb.Append(m_wndView.gameObject.name + " time:" + watch.Elapsed.TotalMilliseconds);
                    //Debug.LogWarning(sb.ToString());
                }
            }
            else
            {
                UISystem.Instance.RemoveWndRenderAfterFillLayerVisible(this);
                //隐藏的时候还原回原来的层
                UISystem.Instance.AddView(m_wndView, GetLayer());
            }
        }
Beispiel #3
0
 public void OnEnable()
 {
     targetUILayer = target as USpeedUILayer;
     if (targetUILayer)
     {
         targetUILayer.RegisterUILayer();
     }
 }
Beispiel #4
0
        public static void UnRegisterUILayer(WndLayerDef _nLayerDef, USpeedUILayer _nLayer)
        {
            if (_nLayerDef == WndLayerDef.WND_LAYER_MAX || _nLayerDef == WndLayerDef.WND_LAYER_NONE)
            {
                return;
            }

            if (instance.m_DicLayer.ContainsKey(_nLayerDef))
            {
                instance.m_DicLayer.Remove(_nLayerDef);
            }
        }
Beispiel #5
0
        private void SetupUILayer(WndLayerDef _nLayerDef)
        {
            USpeedUILayer tmpUILayer = null;

            tmpUILayer = m_layerTransform[(int)_nLayerDef].GetComponent <USpeedUILayer>();
            if (tmpUILayer == null)
            {
                tmpUILayer = m_layerTransform[(int)_nLayerDef].gameObject.AddComponent <USpeedUILayer>();
            }

            tmpUILayer.UILayerDef         = _nLayerDef;
            tmpUILayer.RaycasterLayerMask = 1 << LayerMask.NameToLayer(Config.LayerUI);
        }
Beispiel #6
0
        public static void UnRegisterElementForLayer(USpeedUILayer _nLayer, USpeedUILayerElement _nElement)
        {
            if (_nLayer == null)
            {
                return;
            }

            List <USpeedUILayerElement> layerElements;

            if (instance.m_DicLayerElememt.TryGetValue(_nLayer, out layerElements))
            {
                layerElements.Remove(_nElement);
            }
        }
Beispiel #7
0
        public static void RegisterElementForLayer(USpeedUILayer _nLayer, USpeedUILayerElement _nElement)
        {
            if (_nLayer == null)
            {
                if (!instance.m_ListRegistrationFailed.Contains(_nElement))
                {
                    instance.m_ListRegistrationFailed.Add(_nElement);
                }
                return;
            }

            List <USpeedUILayerElement> layerElements;

            instance.m_DicLayerElememt.TryGetValue(_nLayer, out layerElements);

            if (layerElements != null)
            {
                if (!layerElements.Contains(_nElement))
                {
                    layerElements.Add(_nElement);
                }
            }
            else
            {
                layerElements = new List <USpeedUILayerElement>();
                layerElements.Add(_nElement);
                instance.m_DicLayerElememt.Add(_nLayer, layerElements);
            }

            //重新调整canvas的Sorting信息

            //调整SortingLayer,目前都统一用一个Layer,layer多的话会影响渲染效率
            _nElement.SortingLayerName = _nLayer.LayerCanvas.sortingLayerName;
            //调整SortingOrder
            _nElement.SortingLayerOrder = _nLayer.LayerCanvas.sortingOrder;

            if (instance.m_ListRegistrationFailed.Contains(_nElement) && _nLayer.LayerCanvas.sortingOrder != 0)
            {
                instance.m_ListRegistrationFailed.Remove(_nElement);
            }
        }
Beispiel #8
0
        private void CacheUILayer()
        {
            if (gameObject == null)
            {
                return;
            }
            List <USpeedUILayer> list = new List <USpeedUILayer>();

            gameObject.GetComponentsInParent(false, list);
            if (list.Count > 0)
            {
                m_UILayer = list[0];
            }

            List <IUIWndView> listView = new List <IUIWndView>();

            gameObject.GetComponentsInParent(false, listView);
            if (listView.Count > 0)
            {
                m_UIWndView = listView[0];
            }
        }