diff --git a/com.unity.ml-agents/CHANGELOG.md b/com.unity.ml-agents/CHANGELOG.md index 690af3b6dc..726d3a0161 100755 --- a/com.unity.ml-agents/CHANGELOG.md +++ b/com.unity.ml-agents/CHANGELOG.md @@ -68,6 +68,7 @@ settings. Unfortunately, this may require retraining models if it changes the re or actuators on your system. (#5194) - Removed additional memory allocations that were occurring due to assert messages and iterating of DemonstrationRecorders. (#5246) - Fixed a bug where agent trying to access unintialized fields when creating a new RayPerceptionSensorComponent on an agent. (#5261) +- Fixed a bug where the DemonstrationRecorder would throw a null reference exception if Num Steps To Record was > 0 and Record was turned off. (#5274) #### ml-agents / ml-agents-envs / gym-unity (Python) - Fixed a bug where --results-dir has no effect. (#5269) diff --git a/com.unity.ml-agents/Runtime/Demonstrations/DemonstrationRecorder.cs b/com.unity.ml-agents/Runtime/Demonstrations/DemonstrationRecorder.cs index a074850536..db504c216b 100644 --- a/com.unity.ml-agents/Runtime/Demonstrations/DemonstrationRecorder.cs +++ b/com.unity.ml-agents/Runtime/Demonstrations/DemonstrationRecorder.cs @@ -74,11 +74,14 @@ void OnEnable() void Update() { - if (Record) + if (!Record) { - LazyInitialize(); + return; } + LazyInitialize(); + + // Quit when num steps to record is reached if (NumStepsToRecord > 0 && m_DemoWriter.NumSteps >= NumStepsToRecord) { Application.Quit(0);