void OnEnable() { // Do not move the default initialization below the early out, it's important for the world to exist // if the Subscene gets assigned later, otherwise the change won't trigger an import/conversion. DefaultWorldInitialization.DefaultLazyEditModeInitialize(); GameObjectSceneUtility.RegisterSubScene(gameObject.scene, this); #if UNITY_EDITOR WarnIfNeeded(); _IsAddedToListOfAllSubScenes = true; m_AllSubScenes.Add(this); if (_SceneGUID == default(Hash128)) { return; } if (!IsInMainStage()) { return; } #endif AddSceneEntities(); }
void OnDisable() { #if UNITY_EDITOR _IsAddedToListOfAllSubScenes = false; m_AllSubScenes.Remove(this); #endif RemoveSceneEntities(); GameObjectSceneUtility.UnregisterSubScene(gameObject.scene, this); }