Esempio n. 1
0
        /// <summary>
        /// 设置ui显示层级
        /// </summary>
        /// <param name="ui"></param>
        /// <param name="layer"></param>
        private void SetViewParent(UI_Z ui, string layer)
        {
            RectTransform _rt = ui.GameObject.GetComponent <RectTransform>();

            _rt.SetParent(m_allLayers[layer].transform);
            _rt.anchorMin = Vector2.zero;
            _rt.anchorMax = Vector2.one;
            _rt.offsetMax = Vector2.zero;
            _rt.offsetMin = Vector2.zero;
            _rt.pivot     = new Vector2(0.5f, 0.5f);

            _rt.localScale    = Vector3.one;
            _rt.localPosition = Vector3.zero;
            _rt.localRotation = Quaternion.identity;

            ui.UiComponent.Layer = layer;
        }
Esempio n. 2
0
        public UI_Z Create(Scene scene, string type, GameObject parent)
        {
            try
            {
                ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>();
                resourcesComponent.LoadBundle($"{type}.unity3d");
                GameObject bundleGameObject = resourcesComponent.GetAsset <GameObject>($"{type}.unity3d", $"{type}");
                GameObject newUi            = UnityEngine.Object.Instantiate(bundleGameObject);
                newUi.layer = LayerMask.NameToLayer(LayerNames.UI);
                UI_Z ui = ComponentFactory.Create <UI_Z, GameObject>(newUi);

                //此处务必使用AddUiComponent代替原本et中的AddComponent否则UI_Z中的UiComponent属性会为空
                ui.AddUiComponent <UILoginComponent>();
                return(ui);
            }
            catch (Exception e)
            {
                Log.Error(e.ToStr());
                return(null);
            }
        }
Esempio n. 3
0
 public void Add(UI_Z ui)
 {
     this.children.Add(ui.Name, ui);
     ui.Parent = this;
 }