浏览代码

Merge pull request #55 from mplantady/master

Fix brain type not saved in inspector
/develop-generalizationTraining-TrainerController
GitHub 7 年前
当前提交
6054fcbb
共有 2 个文件被更改,包括 10 次插入8 次删除
  1. 16
      unity-environment/Assets/ML-Agents/Editor/BrainEditor.cs
  2. 2
      unity-environment/Assets/ML-Agents/Scripts/AgentMonitor.cs

16
unity-environment/Assets/ML-Agents/Editor/BrainEditor.cs


EditorGUILayout.HelpBox ("A Brain GameObject must be a child of an Academy GameObject!", MessageType.Error);
} else if (myBrain.transform.parent.GetComponent<Academy> () == null) {
EditorGUILayout.HelpBox ("The Parent of a Brain must have an Academy Component attached to it!", MessageType.Error);
}
}
SerializedProperty bp = serializedBrain.FindProperty ("brainParameters");

if (myBrain.brainParameters.actionSize != myBrain.brainParameters.actionDescriptions.Count()) {
myBrain.brainParameters.actionDescriptions = new string[myBrain.brainParameters.actionSize];
}
serializedBrain.Update ();
EditorGUILayout.PropertyField (bp, true);
serializedBrain.ApplyModifiedProperties ();
serializedBrain.Update();
EditorGUILayout.PropertyField(bp, true);
myBrain.brainType = (BrainType)EditorGUILayout.EnumPopup ("Type Of Brain ", myBrain.brainType);
SerializedProperty bt = serializedBrain.FindProperty("brainType");
EditorGUILayout.PropertyField(bt);
if ((int)myBrain.brainType >= System.Enum.GetValues (typeof(BrainType)).Length) {
myBrain.brainType = BrainType.Player;
if (bt.enumValueIndex < 0) {
bt.enumValueIndex = (int)BrainType.Player;
serializedBrain.ApplyModifiedProperties();
myBrain.UpdateCoreBrains ();

2
unity-environment/Assets/ML-Agents/Scripts/AgentMonitor.cs


}
else
{
texts.text += "State : " + ((int)agent.agentStoredAction[0]).ToString() + "\n";
texts.text += "Action : " + ((int)agent.agentStoredAction[0]).ToString() + "\n";
}
}

正在加载...
取消
保存