浏览代码
[change] public SensorComponent fields to properties, add custom editor (#3564)
/bug-failed-api-check
[change] public SensorComponent fields to properties, add custom editor (#3564)
/bug-failed-api-check
GitHub
5 年前
当前提交
2a630030
共有 13 个文件被更改,包括 276 次插入 和 53 次删除
-
1com.unity.ml-agents/CHANGELOG.md
-
10com.unity.ml-agents/Editor/RayPerceptionSensorComponentBaseEditor.cs
-
4com.unity.ml-agents/Runtime/Policies/BehaviorParameters.cs
-
19com.unity.ml-agents/Runtime/Sensors/CameraSensor.cs
-
78com.unity.ml-agents/Runtime/Sensors/CameraSensorComponent.cs
-
8com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensorComponent3D.cs
-
31com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensorComponentBase.cs
-
10com.unity.ml-agents/Runtime/Sensors/RenderTextureSensor.cs
-
55com.unity.ml-agents/Runtime/Sensors/RenderTextureSensorComponent.cs
-
48com.unity.ml-agents/Editor/CameraSensorComponentEditor.cs
-
11com.unity.ml-agents/Editor/CameraSensorComponentEditor.cs.meta
-
43com.unity.ml-agents/Editor/RenderTextureSensorComponentEditor.cs
-
11com.unity.ml-agents/Editor/RenderTextureSensorComponentEditor.cs.meta
|
|||
using UnityEngine; |
|||
using UnityEditor; |
|||
using MLAgents.Sensors; |
|||
|
|||
namespace MLAgents.Editor |
|||
{ |
|||
[CustomEditor(typeof(CameraSensorComponent))] |
|||
[CanEditMultipleObjects] |
|||
internal class CameraSensorComponentEditor : UnityEditor.Editor |
|||
{ |
|||
public override void OnInspectorGUI() |
|||
{ |
|||
var so = serializedObject; |
|||
so.Update(); |
|||
|
|||
// Drawing the CameraSensorComponent
|
|||
EditorGUI.BeginChangeCheck(); |
|||
|
|||
EditorGUILayout.PropertyField(so.FindProperty("m_Camera"), true); |
|||
EditorGUI.BeginDisabledGroup(Application.isPlaying); |
|||
{ |
|||
// 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_Width"), true); |
|||
EditorGUILayout.PropertyField(so.FindProperty("m_Height"), true); |
|||
EditorGUILayout.PropertyField(so.FindProperty("m_Grayscale"), true); |
|||
} |
|||
EditorGUI.EndDisabledGroup(); |
|||
EditorGUILayout.PropertyField(so.FindProperty("m_Compression"), true); |
|||
|
|||
var requireSensorUpdate = EditorGUI.EndChangeCheck(); |
|||
so.ApplyModifiedProperties(); |
|||
|
|||
if (requireSensorUpdate) |
|||
{ |
|||
UpdateSensor(); |
|||
} |
|||
} |
|||
|
|||
void UpdateSensor() |
|||
{ |
|||
var sensorComponent = serializedObject.targetObject as CameraSensorComponent; |
|||
sensorComponent?.UpdateSensor(); |
|||
} |
|||
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: fdda773c024894cf0ae47d1b1396c38d |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
using UnityEditor; |
|||
using MLAgents.Sensors; |
|||
namespace MLAgents.Editor |
|||
{ |
|||
[CustomEditor(typeof(RenderTextureSensorComponent))] |
|||
[CanEditMultipleObjects] |
|||
internal class RenderTextureSensorComponentEditor : UnityEditor.Editor |
|||
{ |
|||
public override void OnInspectorGUI() |
|||
{ |
|||
var so = serializedObject; |
|||
so.Update(); |
|||
|
|||
// Drawing the RenderTextureComponent
|
|||
EditorGUI.BeginChangeCheck(); |
|||
|
|||
EditorGUI.BeginDisabledGroup(Application.isPlaying); |
|||
{ |
|||
EditorGUILayout.PropertyField(so.FindProperty("m_RenderTexture"), true); |
|||
EditorGUILayout.PropertyField(so.FindProperty("m_SensorName"), true); |
|||
EditorGUILayout.PropertyField(so.FindProperty("m_Grayscale"), true); |
|||
} |
|||
EditorGUI.EndDisabledGroup(); |
|||
|
|||
EditorGUILayout.PropertyField(so.FindProperty("m_Compression"), true); |
|||
|
|||
var requireSensorUpdate = EditorGUI.EndChangeCheck(); |
|||
so.ApplyModifiedProperties(); |
|||
|
|||
if (requireSensorUpdate) |
|||
{ |
|||
UpdateSensor(); |
|||
} |
|||
} |
|||
|
|||
void UpdateSensor() |
|||
{ |
|||
var sensorComponent = serializedObject.targetObject as RenderTextureSensorComponent; |
|||
sensorComponent?.UpdateSensor(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: dab309e01d2964f0792de3ef914ca6b9 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue