vincentpierre
4 年前
当前提交
b293dd9e
共有 9 个文件被更改,包括 170 次插入 和 7 次删除
-
1com.unity.ml-agents/Editor/CameraSensorComponentEditor.cs
-
19com.unity.ml-agents/Runtime/Sensors/CameraSensor.cs
-
15com.unity.ml-agents/Runtime/Sensors/CameraSensorComponent.cs
-
4com.unity.ml-agents/Runtime/Sensors/ITypedSensor.cs
-
12com.unity.ml-agents/Runtime/Sensors/VectorSensor.cs
-
42com.unity.ml-agents/Editor/VectorSensorComponentEditor.cs
-
11com.unity.ml-agents/Editor/VectorSensorComponentEditor.cs.meta
-
62com.unity.ml-agents/Runtime/Sensors/VectorSensorComponent.cs
-
11com.unity.ml-agents/Runtime/Sensors/VectorSensorComponent.cs.meta
|
|||
using UnityEditor; |
|||
using Unity.MLAgents.Sensors; |
|||
|
|||
namespace Unity.MLAgents.Editor |
|||
{ |
|||
[CustomEditor(typeof(VectorSensorComponent))] |
|||
[CanEditMultipleObjects] |
|||
internal class VectorSensorComponentEditor : UnityEditor.Editor |
|||
{ |
|||
public override void OnInspectorGUI() |
|||
{ |
|||
var so = serializedObject; |
|||
so.Update(); |
|||
|
|||
// Drawing the VectorSensorComponent
|
|||
EditorGUI.BeginChangeCheck(); |
|||
|
|||
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_observationSize"), true); |
|||
EditorGUILayout.PropertyField(so.FindProperty("m_ObservationType"), true); |
|||
} |
|||
EditorGUI.EndDisabledGroup(); |
|||
|
|||
var requireSensorUpdate = EditorGUI.EndChangeCheck(); |
|||
so.ApplyModifiedProperties(); |
|||
|
|||
if (requireSensorUpdate) |
|||
{ |
|||
UpdateSensor(); |
|||
} |
|||
} |
|||
|
|||
void UpdateSensor() |
|||
{ |
|||
var sensorComponent = serializedObject.targetObject as VectorSensorComponent; |
|||
sensorComponent?.UpdateSensor(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 4e900f9ce9be541c69e45ae94956932f |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
using UnityEngine.Serialization; |
|||
|
|||
namespace Unity.MLAgents.Sensors |
|||
{ |
|||
[AddComponentMenu("ML Agents/Vector Sensor", (int)MenuGroup.Sensors)] |
|||
public class VectorSensorComponent : SensorComponent |
|||
{ |
|||
public int ObservationSize |
|||
{ |
|||
get { return m_observationSize; } |
|||
set { m_observationSize = value; } |
|||
} |
|||
|
|||
[HideInInspector, SerializeField] |
|||
int m_observationSize; |
|||
|
|||
[HideInInspector, SerializeField] |
|||
ObservationType m_ObservationType; |
|||
|
|||
VectorSensor m_sensor; |
|||
|
|||
public ObservationType ObservationType |
|||
{ |
|||
get { return m_ObservationType; } |
|||
set { m_ObservationType = value; } |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Creates a VectorSensor.
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
public override ISensor CreateSensor() |
|||
{ |
|||
m_sensor = new VectorSensor(m_observationSize, observationType: m_ObservationType); |
|||
return m_sensor; |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
public override int[] GetObservationShape() |
|||
{ |
|||
return new[] { m_observationSize }; |
|||
} |
|||
|
|||
public VectorSensor GetSensor() |
|||
{ |
|||
return m_sensor; |
|||
} |
|||
|
|||
|
|||
/// <summary>
|
|||
/// Update fields that are safe to change on the Sensor at runtime.
|
|||
/// </summary>
|
|||
internal void UpdateSensor() |
|||
{ |
|||
if (m_sensor != null) |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 58239d05cfbbd4ac1b22ba12865beca3 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue