void RestartTemporalSimulation() { // We default to preserving data when restarting simulation, but this can be changed in the // BeforeTemporalSimulationRestart callback KeepDataBetweenSimulations = true; BeforeTemporalSimulationRestart?.Invoke(); if (!KeepDataBetweenSimulations) { StopTemporalSimulationInternal(); StartTemporalSimulation(); return; } m_EnvironmentManager.UpdateDeviceStartingPose(); StopSimulation(); m_SimulatedObjectsManager.StopRunningSimulatables(); TriggerOnTemporalSimulationStop(); if (m_QueryPipelinesModule != null) { m_QueryPipelinesModule.StandalonePipeline.ClearData(); } if (!TryStartSimulation()) { simulatingTemporal = false; return; } TriggerOnTemporalSimulationStart(); }
/// <summary> /// If any objects are using the simulation scene, this method sets a flag that a new simulation should happen as soon as possible /// </summary> /// <param name="stopSimulationImmediately">If true and if temporal simulation is running, this method will /// immediately stop simulation. If <see cref="SimulationModeSelection.TemporalMode"/> has been requested for the /// next simulation then this method will invoke <see cref="BeforeTemporalSimulationRestart"/> before stopping simulation.</param> public void RestartSimulationIfNeeded(bool stopSimulationImmediately = false) { if (SimulationSceneModule.UsingSimulation) { if (stopSimulationImmediately && simulatingTemporal) { if (NextSimModeSelection == SimulationModeSelection.TemporalMode) { BeforeTemporalSimulationRestart?.Invoke(); } StopTemporalSimulationInternal(); } m_SimulationRestartNeeded = true; if (MarsDebugSettings.QuerySimulationModuleLogging) { Debug.Log("simulation restart needed"); } } }