/// <inheritdoc/> void IModule.LoadModule() { if (!m_SceneModule.simulateInPlaymode && Application.isPlaying) { return; } // TODO: Move environment manager functionality to runtime assembly EditorOnlyDelegates.OpenSimulationScene = OpenSimulation; EditorOnlyDelegates.GetSimulatedContentRoot = () => ContentRoot; instance = this; if (!SimulationSceneUsers.instance) { m_SimulationSceneUsers = SimulationSceneUsers.CreateSimulationSceneSubscribers(); } else { m_SimulationSceneUsers = SimulationSceneUsers.instance; } if (m_SceneModule.simulateInPlaymode && EditorApplication.isPlayingOrWillChangePlaymode) { m_SimulationSceneUsers.AddSimulationUser(MARSSceneModule.instance); m_SceneModuleIsUser = true; } if (!Application.isPlaying) { OpenSimulation(); } AssemblyReloadEvents.afterAssemblyReload += OnAfterAssemblyReload; AssemblyReloadEvents.beforeAssemblyReload += OnBeforeAssemblyReload; }
/// <inheritdoc/> void IModule.UnloadModule() { if (m_SimulationSceneUsers && m_SceneModuleIsUser) { m_SimulationSceneUsers.RemoveSimulationUser(MARSSceneModule.instance); } EditorOnlyDelegates.GetSimulatedContentRoot = null; EditorOnlyDelegates.OpenSimulationScene = null; CloseSimulation(); AssemblyReloadEvents.afterAssemblyReload -= OnAfterAssemblyReload; AssemblyReloadEvents.beforeAssemblyReload -= OnBeforeAssemblyReload; instance = null; }
void IModuleDependency <SimulationSceneModule> .ConnectDependency(SimulationSceneModule dependency) { m_SimulationSceneModule = dependency; }