浏览代码

Fix Demonstration recorder null reference bug (#1994)

* Fix for recording mid-play

* Change docstring

* Add additional null check
/develop-generalizationTraining-TrainerController
GitHub 6 年前
当前提交
fd6e44de
共有 1 个文件被更改,包括 26 次插入13 次删除
  1. 39
      UnitySDK/Assets/ML-Agents/Scripts/DemonstrationRecorder.cs

39
UnitySDK/Assets/ML-Agents/Scripts/DemonstrationRecorder.cs


using UnityEngine;
using UnityEngine;
using System.Text.RegularExpressions;
namespace MLAgents

private DemonstrationStore demoStore;
public const int MAX_NAME_LENGTH = 16;
/// <summary>
/// Initializes Demonstration store.
/// </summary>
recordingAgent = GetComponent<Agent>();
demoStore = new DemonstrationStore();
demonstrationName = SanitizeName(demonstrationName, MAX_NAME_LENGTH);
demoStore.Initialize(
demonstrationName,
recordingAgent.brain.brainParameters,
recordingAgent.brain.name);
Monitor.Log("Recording Demonstration of Agent: ", recordingAgent.name);
InitializeDemoStore();
}
}
private void Update()
{
if (Application.isEditor && record && demoStore == null)
{
InitializeDemoStore();
}
/// <summary>
/// Creates demonstration store for use in recording.
/// </summary>
private void InitializeDemoStore()
{
recordingAgent = GetComponent<Agent>();
demoStore = new DemonstrationStore();
demonstrationName = SanitizeName(demonstrationName);
demoStore.Initialize(
demonstrationName,
recordingAgent.brain.brainParameters,
recordingAgent.brain.name);
Monitor.Log("Recording Demonstration of Agent: ", recordingAgent.name);
}
/// <summary>

/// </summary>
private void OnApplicationQuit()
{
if (Application.isEditor && record)
if (Application.isEditor && record && demoStore != null)
{
demoStore.Close();
}

正在加载...
取消
保存