Пример #1
0
        private void DetachHost()
        {
            if (_hostObject != null)
            {
                if (_canDestroyHost)
                {
                    GameObjectFinder.DestroyFinder(_objFinder);
                    UnityEngine.Object.Destroy(_hostObject);
                }
                _view       = null;
                _hostObject = null;
                _objFinder  = null;
            }
            else
            {
                // TODO:
                //visible = false;
                if (_behaviour != null)
                {
                    UnityEngine.Object.Destroy(_behaviour);
                    _behaviour = null;
                }
            }

            //UnloadAssets();
        }
Пример #2
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();
        }