Exemplo n.º 1
0
        public void Init(GameObject gameObject, UILayerConfig uiLayerConfig)
        {
            base.Init();
            this.uiLayerConfig = uiLayerConfig;
            this.graphicComponent.SetGameObject(gameObject, true);
            gameObject.name  = uiLayerConfig.name.ToString();
            gameObject.layer = LayerMask.NameToLayer("UI");

            RectTransform rectTransform = graphicComponent.gameObject.GetOrAddComponent <RectTransform>();

            rectTransform.anchorMin          = new Vector2(0, 0);
            rectTransform.anchorMax          = new Vector2(1, 1);
            rectTransform.sizeDelta          = new Vector2(0, 0);
            rectTransform.anchoredPosition3D = new Vector3(0, 0, 0);
            rectTransform.localScale         = new Vector3(1, 1, 1);
        }
Exemplo n.º 2
0
        public void Init(UIManager uiManager)
        {
            base.Init();
            this.uiManager = uiManager;
            for (int i = 0; i < UILayerConst.uiLayerConfigDict.Values.Count; i++)
            {
                UILayerConfig uiLayerConfig   = UILayerConst.uiLayerConfigDict.Values[i];
                string        name            = uiLayerConfig.name.ToString();
                Transform     layerTransform  = uiManager.graphicComponent.transform.Find("UICanvas/" + name);
                GameObject    layerGameObject = layerTransform != null ? layerTransform.gameObject : new GameObject(name);
                layerGameObject.transform.SetParent(uiManager.uiCanvas.transform);
                layerGameObject.transform.SetSiblingIndex(i);
                var layer = this.AddChild <UILayer>(null, layerGameObject, uiLayerConfig);
                uiLayerDict[uiLayerConfig.name] = layer;
            }

            this.AddListener <EUILayerName, bool>(null, UIEventNameConst.SetIsHideUILayer, SetIsHideUILayer);
        }