浏览代码

Adding a custom editor for BufferSensorComponent

/develop/gail-srl-hack
vincentpierre 3 年前
当前提交
2dba37a0
共有 3 个文件被更改,包括 58 次插入4 次删除
  1. 20
      com.unity.ml-agents/Runtime/Sensors/BufferSensorComponent.cs
  2. 31
      com.unity.ml-agents/Editor/BufferSensorComponentEditor.cs
  3. 11
      com.unity.ml-agents/Editor/BufferSensorComponentEditor.cs.meta

20
com.unity.ml-agents/Runtime/Sensors/BufferSensorComponent.cs


get { return m_SensorName; }
set { m_SensorName = value; }
}
public string m_SensorName = "BufferSensor";
[HideInInspector, SerializeField]
private string m_SensorName = "BufferSensor";
public int ObservableSize;
public int ObservableSize
{
get { return m_ObservableSize; }
set { m_ObservableSize = value; }
}
[HideInInspector, SerializeField]
private int m_ObservableSize;
public int MaxNumObservables;
public int MaxNumObservables
{
get { return m_MaxNumObservables; }
set { m_MaxNumObservables = value; }
}
[HideInInspector, SerializeField]
private int m_MaxNumObservables;
private BufferSensor m_Sensor;

31
com.unity.ml-agents/Editor/BufferSensorComponentEditor.cs


using UnityEditor;
using Unity.MLAgents.Sensors;
namespace Unity.MLAgents.Editor
{
[CustomEditor(typeof(BufferSensorComponent))]
[CanEditMultipleObjects]
internal class BufferSensorComponentEditor : UnityEditor.Editor
{
public override void OnInspectorGUI()
{
var so = serializedObject;
so.Update();
// Drawing the BufferSensorComponent
EditorGUI.BeginDisabledGroup(!EditorUtilities.CanUpdateModelProperties());
{
// These fields affect the sensor order or observation size,
// So can't be changed at runtime.
EditorGUILayout.PropertyField(so.FindProperty("m_SensorName"), true);
EditorGUILayout.PropertyField(so.FindProperty("m_ObservableSize"), true);
EditorGUILayout.PropertyField(so.FindProperty("m_MaxNumObservables"), true);
}
EditorGUI.EndDisabledGroup();
so.ApplyModifiedProperties();
}
}
}

11
com.unity.ml-agents/Editor/BufferSensorComponentEditor.cs.meta


fileFormatVersion: 2
guid: b042fe65027f94c1eb38a2ee1362d38d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存