GitHub
5 年前
当前提交
ca914546
共有 6 个文件被更改,包括 285 次插入 和 55 次删除
-
2com.unity.ml-agents/CHANGELOG.md
-
8com.unity.ml-agents/Runtime/Sensor/RayPerceptionSensor.cs
-
22com.unity.ml-agents/Runtime/Sensor/RayPerceptionSensorComponent3D.cs
-
203com.unity.ml-agents/Runtime/Sensor/RayPerceptionSensorComponentBase.cs
-
94com.unity.ml-agents/Editor/RayPerceptionSensorComponentBaseEditor.cs
-
11com.unity.ml-agents/Editor/RayPerceptionSensorComponentBaseEditor.cs.meta
|
|||
using UnityEngine; |
|||
using UnityEditor; |
|||
using Barracuda; |
|||
|
|||
namespace MLAgents |
|||
{ |
|||
internal class RayPerceptionSensorComponentBaseEditor : Editor |
|||
{ |
|||
bool m_RequireSensorUpdate; |
|||
|
|||
protected void OnRayPerceptionInspectorGUI(bool is3d) |
|||
{ |
|||
var so = serializedObject; |
|||
so.Update(); |
|||
|
|||
// Drawing the RayPerceptionSensorComponent
|
|||
EditorGUI.BeginChangeCheck(); |
|||
EditorGUI.indentLevel++; |
|||
|
|||
EditorGUILayout.PropertyField(so.FindProperty("m_SensorName"), true); |
|||
|
|||
// Because the number of rays and the tags affect the observation shape,
|
|||
// they are not editable during play mode.
|
|||
EditorGUI.BeginDisabledGroup(Application.isPlaying); |
|||
{ |
|||
EditorGUILayout.PropertyField(so.FindProperty("m_DetectableTags"), true); |
|||
EditorGUILayout.PropertyField(so.FindProperty("m_RaysPerDirection"), true); |
|||
} |
|||
EditorGUI.EndDisabledGroup(); |
|||
|
|||
EditorGUILayout.PropertyField(so.FindProperty("m_MaxRayDegrees"), true); |
|||
EditorGUILayout.PropertyField(so.FindProperty("m_SphereCastRadius"), true); |
|||
EditorGUILayout.PropertyField(so.FindProperty("m_RayLength"), true); |
|||
EditorGUILayout.PropertyField(so.FindProperty("m_RayLayerMask"), true); |
|||
|
|||
// Because the number of observation stacks affects the observation shape,
|
|||
// it is not editable during play mode.
|
|||
EditorGUI.BeginDisabledGroup(Application.isPlaying); |
|||
{ |
|||
EditorGUILayout.PropertyField(so.FindProperty("m_ObservationStacks"), true); |
|||
} |
|||
EditorGUI.EndDisabledGroup(); |
|||
|
|||
if (is3d) |
|||
{ |
|||
EditorGUILayout.PropertyField(so.FindProperty("m_StartVerticalOffset"), true); |
|||
EditorGUILayout.PropertyField(so.FindProperty("m_EndVerticalOffset"), true); |
|||
} |
|||
|
|||
EditorGUILayout.PropertyField(so.FindProperty("rayHitColor"), true); |
|||
EditorGUILayout.PropertyField(so.FindProperty("rayMissColor"), true); |
|||
|
|||
EditorGUI.indentLevel--; |
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
m_RequireSensorUpdate = true; |
|||
} |
|||
|
|||
UpdateSensorIfDirty(); |
|||
so.ApplyModifiedProperties(); |
|||
} |
|||
|
|||
|
|||
void UpdateSensorIfDirty() |
|||
{ |
|||
if (m_RequireSensorUpdate) |
|||
{ |
|||
var sensorComponent = serializedObject.targetObject as RayPerceptionSensorComponentBase; |
|||
sensorComponent?.UpdateSensor(); |
|||
m_RequireSensorUpdate = false; |
|||
} |
|||
} |
|||
} |
|||
|
|||
[CustomEditor(typeof(RayPerceptionSensorComponent2D))] |
|||
[CanEditMultipleObjects] |
|||
internal class RayPerceptionSensorComponent2DEditor : RayPerceptionSensorComponentBaseEditor |
|||
{ |
|||
public override void OnInspectorGUI() |
|||
{ |
|||
OnRayPerceptionInspectorGUI(false); |
|||
} |
|||
} |
|||
|
|||
[CustomEditor(typeof(RayPerceptionSensorComponent3D))] |
|||
[CanEditMultipleObjects] |
|||
internal class RayPerceptionSensorComponent3DEditor : RayPerceptionSensorComponentBaseEditor |
|||
{ |
|||
public override void OnInspectorGUI() |
|||
{ |
|||
OnRayPerceptionInspectorGUI(true); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c0182483e53c24d0e9f264f711ed89a9 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue