|
|
|
|
|
|
void OnDisable() |
|
|
|
{ |
|
|
|
s_ActiveScenario = null; |
|
|
|
StopCoroutine(UpdateLoop()); |
|
|
|
} |
|
|
|
|
|
|
|
IEnumerator Start() |
|
|
|
|
|
|
foreach (var config in ParameterConfiguration.configurations) |
|
|
|
config.ValidateParameters(); |
|
|
|
OnInitialize(); |
|
|
|
|
|
|
|
|
|
|
|
StartCoroutine(UpdateLoop()); |
|
|
|
IEnumerator UpdateLoop() |
|
|
|
void Update() |
|
|
|
while (!isScenarioComplete) |
|
|
|
if (isScenarioComplete) |
|
|
|
{ |
|
|
|
OnComplete(); |
|
|
|
DatasetCapture.ResetSimulation(); |
|
|
|
if (quitOnComplete) |
|
|
|
#if UNITY_EDITOR
|
|
|
|
UnityEditor.EditorApplication.isPlaying = false; |
|
|
|
#else
|
|
|
|
Application.Quit(); |
|
|
|
#endif
|
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (isIterationComplete) |
|
|
|
{ |
|
|
|
currentIteration++; |
|
|
|
currentIterationFrame = 0; |
|
|
|
OnIterationTeardown(); |
|
|
|
} |
|
|
|
|
|
|
|
if (currentIterationFrame == 0) |
|
|
|
{ |
|
|
|
DatasetCapture.StartNewSequence(); |
|
|
|
foreach (var config in ParameterConfiguration.configurations) |
|
|
|
|
|
|
OnIterationSetup(); |
|
|
|
while (!isIterationComplete) |
|
|
|
{ |
|
|
|
foreach (var config in ParameterConfiguration.configurations) |
|
|
|
config.ApplyParameters(framesSinceInitialization, ParameterApplicationFrequency.EveryFrame); |
|
|
|
OnFrameStart(); |
|
|
|
yield return null; |
|
|
|
currentIterationFrame++; |
|
|
|
framesSinceInitialization++; |
|
|
|
} |
|
|
|
currentIteration++; |
|
|
|
currentIterationFrame = 0; |
|
|
|
OnIterationTeardown(); |
|
|
|
OnComplete(); |
|
|
|
DatasetCapture.ResetSimulation(); |
|
|
|
if (quitOnComplete) |
|
|
|
#if UNITY_EDITOR
|
|
|
|
UnityEditor.EditorApplication.isPlaying = false; |
|
|
|
#else
|
|
|
|
Application.Quit(); |
|
|
|
#endif
|
|
|
|
foreach (var config in ParameterConfiguration.configurations) |
|
|
|
config.ApplyParameters(framesSinceInitialization, ParameterApplicationFrequency.EveryFrame); |
|
|
|
OnFrameStart(); |
|
|
|
currentIterationFrame++; |
|
|
|
framesSinceInitialization++; |
|
|
|
} |
|
|
|
} |
|
|
|
} |