/// <summary> /// The object has been enabled. /// </summary> private void OnEnable() { // The object may have been enabled outside of the scene unloading. if (s_Instance == null) { s_Instance = this; s_Initialized = true; SceneManager.sceneUnloaded -= SceneUnloaded; // Characters and cameras may be marked DontDestroyOnLoad. Reregister any active objects. var characterLocomotions = FindObjectsOfType <UltimateCharacterLocomotion>(); for (int i = 0; i < characterLocomotions.Length; ++i) { if (characterLocomotions[i].KinematicObjectIndex == -1) { continue; } // The character is active. characterLocomotions[i].KinematicObjectIndex = RegisterCharacter(characterLocomotions[i]); } var cameras = FindObjectsOfType <CameraController>(); for (int i = 0; i < cameras.Length; ++i) { if (cameras[i].KinematicObjectIndex == -1) { continue; } // The camera is active. cameras[i].KinematicObjectIndex = RegisterCamera(cameras[i]); } } }
/// <summary> /// Reset the initialized variable when the scene is no longer loaded. /// </summary> /// <param name="scene">The scene that was unloaded.</param> private void SceneUnloaded(Scene scene) { s_Initialized = false; s_Instance = null; SceneManager.sceneUnloaded -= SceneUnloaded; UnityEngineUtility.ClearCache(); }
/// <summary> /// The object has been enabled. /// </summary> private void OnEnable() { // The object may have been enabled outside of the scene unloading. if (s_Instance == null) { s_Instance = this; s_Initialized = true; SceneManager.sceneUnloaded -= SceneUnloaded; } }
/// <summary> /// Unregisters the object with the Kinematic Object Manager. /// </summary> public void OnDisable() { KinematicObjectManager.UnregisterKinematicObject(m_KinematicObjectIndex); }
/// <summary> /// Registers the object with the Kinematic Object Manager. /// </summary> public void OnEnable() { m_KinematicObjectIndex = KinematicObjectManager.RegisterKinematicObject(this); m_LastPosition = m_Transform.position; m_LastRotation = m_Transform.rotation; }
private static void DomainReset() { s_Initialized = false; s_Instance = null; }