浏览代码

BrainEditor: Replaced `new SerializedObject()` with property. (#88)

* Fixed `Academy` children `Brain` gathering.

* Brain-Editor: Replaced `new SerializedObject()` with `serializedObject`.

* BrainEditor: Simplified `if` condition for `BrainParameters` checks.
/develop-generalizationTraining-TrainerController
Arthur Juliani 7 年前
当前提交
cca45d1f
共有 1 个文件被更改,包括 7 次插入14 次删除
  1. 21
      unity-environment/Assets/ML-Agents/Editor/BrainEditor.cs

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


[CustomEditor (typeof(Brain))]
public class BrainEditor : Editor
{
SerializedObject serializedBrain = new SerializedObject (target);
SerializedObject serializedBrain = serializedObject;
if (myBrain.transform.parent == null) {
EditorGUILayout.HelpBox ("A Brain GameObject must be a child of an Academy GameObject!", MessageType.Error);

BrainParameters parameters = myBrain.brainParameters;
if (parameters.actionDescriptions == null || parameters.actionDescriptions.Length != parameters.actionSize)
parameters.actionDescriptions = new string[parameters.actionSize];
serializedBrain.Update();
if (myBrain.brainParameters.actionDescriptions == null) {
myBrain.brainParameters.actionDescriptions = new string[myBrain.brainParameters.actionSize];
}
if (myBrain.brainParameters.actionSize != myBrain.brainParameters.actionDescriptions.Count()) {
myBrain.brainParameters.actionDescriptions = new string[myBrain.brainParameters.actionSize];
}
serializedBrain.Update();
EditorGUILayout.PropertyField(bp, true);
SerializedProperty bt = serializedBrain.FindProperty("brainType");

serializedBrain.ApplyModifiedProperties();
myBrain.UpdateCoreBrains ();
}
}
正在加载...
取消
保存