Example #1
0
        internal void SetGameObject(GameObject gameObject, object data = null)
        {
            this.gameObject = gameObject;
            var isActive = this.gameObject.activeInHierarchy;

            AutoReference();

            _z            = ComponentUtil.AutoGet <ZeroView>(this.gameObject);
            _z.aViewClass = GetType().FullName;
            _z.onEnable  += OnGameObjectEnable;
            _z.onDisable += OnGameObjectDisable;
            _z.onDestroy += OnGameObjectDestroy;

            OnInit(data);

            /*
             * 通过isActive来限定,只有当gameObject本来为activeInHierarchy状态,
             * 并且执行OnInit后还在activeInHierarchy状态时,才调用OnEnable,因为
             * OnInit中可能执行了SetActive,并且触发了OnGameObjectEnable或OnGameObjectDisable
             */
            if (isActive && this.gameObject.activeInHierarchy)
            {
                OnEnable();
            }
        }
Example #2
0
 private void OnGameObjectDestroy()
 {
     _z         = null;
     gameObject = null;
     OnDestroy();
     onDestroyed?.Invoke(this);
 }
        public JsonResult AddView(string path, string title)
        {
            EnsureProjectLoaded(path);

            ZeroView view = this._zeroProjectsService.AddViewToProject(path, title);

            return(Json(view));
        }
Example #4
0
 private void OnGameObjectDestroy()
 {
     _z         = null;
     gameObject = null;
     OnDestroy();
     if (null != onDestroyHandler)
     {
         onDestroyHandler.Invoke(this);
     }
 }
Example #5
0
        internal ZeroView AddViewToProject(string projectPath, string viewTitle)
        {
            if (this._projectsMap.ContainsKey(projectPath))
            {
                ZeroProject project = this._projectsMap[projectPath];
                ZeroView    view    = project.AddView(viewTitle);

                return(view);
            }

            return(null);
        }
Example #6
0
        internal void SetGameObject(GameObject gameObject, object data = null)
        {
            this.gameObject = gameObject;

            _z            = ComponentUtil.AutoGet <ZeroView>(this.gameObject);
            _z.aViewClass = GetType().FullName;
            _z.onEnable  += OnGameObjectEnable;
            _z.onDisable += OnGameObjectDisable;
            _z.onDestroy += OnGameObjectDestroy;

            OnInit(data);

            if (this.gameObject.activeInHierarchy)
            {
                OnEnable();
            }
        }