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(); } }
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)); }
private void OnGameObjectDestroy() { _z = null; gameObject = null; OnDestroy(); if (null != onDestroyHandler) { onDestroyHandler.Invoke(this); } }
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); }
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(); } }