コード例 #1
0
        protected void AttachHost(GameObject host, bool beClone = true, bool canDestroyHost = true)
        {
            if (_destroyed)
            {
                return;
            }

            _canDestroyHost = canDestroyHost;

            bool isFirstCreated = _hostObject == null;

            if (isFirstCreated)
            {
                _hostObject = beClone ? UnityEngine.Object.Instantiate(host) : host;
                _view       = _hostObject.transform;
                _objFinder  = GameObjectFinder.CreateFinder(_hostObject);
            }

            if (_behaviour == null)
            {
                _behaviour      = _hostObject.AddComponent <ViewBehaviour>();
                _behaviour.View = this;
                //_behaviour.enabled = enabled;
            }
            else if (!_behaviour.enabled)
            {
                _behaviour.enabled = true;
            }

            UpdateParent();

            // TODO:
            ////场景激活后才能够打开托管类型view
            //if (Main.currentScene != null && !(this is IRender)) {
            //    if (_visible && destroyType != ViewInstanceType.MANUAL_DISPOSE && Main.currentScene.statu < SceneProcessStatu.CREATIONCOMPLETE) {
            //        Main.currentScene.AddActiveView(this);
            //    }
            //}

            if (isFirstCreated)
            {
                OnAttachHost();
            }

            _hostObject.SetActive(false);

            ShowView();
        }
コード例 #2
0
ファイル: UIManager.cs プロジェクト: parlace/Fountain
        public static void Init()
        {
            if (_uiRoot != null)
            {
                return;
            }

            _uiRoot = GameObject.Find("GameApp/UIRoot");

            GameObjectFinder finder = GameObjectFinder.CreateFinder(_uiRoot);

            #region Camera
            _uiCamera = finder.GetComponent <Camera>("UICamera");
            if (_uiCamera != null)
            {
                _uiCamera.clearFlags              = CameraClearFlags.Depth;
                _uiCamera.farClipPlane            = 10000;
                _uiCamera.transform.localPosition = new Vector3(0f, 0f, -50000);
            }
            #endregion

            #region EventSystem
            _eventSystem = finder.GetComponent <EventSystem>("EventSystem");
            if (_eventSystem != null)
            {
            }
            #endregion

            #region Layer
            AddUILayer(UILayer.BaseLayer, ref finder, 0f);
            AddUILayer(UILayer.WindowLayer, ref finder, -10000f);
            AddUILayer(UILayer.TopLayer, ref finder, -20000f);
            AddUILayer(UILayer.ModalLayer, ref finder, -30000f);
            AddUILayer(UILayer.SystemLayer, ref finder, -40000f);
            #endregion
        }