Skip to content

Commit 04a02c1

Browse files
author
Chris Elion
authored
[MLA-1939] Match3 Custom Editor (#5263)
1 parent 3cf5968 commit 04a02c1

14 files changed

+135
-21
lines changed

Project/Assets/ML-Agents/Examples/Match3/Scripts/Match3ExampleActuator.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using Unity.MLAgents;
21
using Unity.MLAgents.Integrations.Match3;
32

43
namespace Unity.MLAgentsExamples

Project/Assets/ML-Agents/Examples/Match3/Scripts/Match3ExampleActuatorComponent.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ public class Match3ExampleActuatorComponent : Match3ActuatorComponent
1010
public override IActuator[] CreateActuators()
1111
{
1212
var board = GetComponent<Match3Board>();
13-
var agent = GetComponentInParent<Agent>();
1413
var seed = RandomSeed == -1 ? gameObject.GetInstanceID() : RandomSeed + 1;
1514
return new IActuator[] { new Match3ExampleActuator(board, ForceHeuristic, ActuatorName, seed) };
1615
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace Unity.MLAgents.Editor
55
{
6-
[CustomEditor(typeof(BufferSensorComponent))]
6+
[CustomEditor(typeof(BufferSensorComponent), editorForChildClasses: true)]
77
[CanEditMultipleObjects]
88
internal class BufferSensorComponentEditor : UnityEditor.Editor
99
{

com.unity.ml-agents/Editor/CameraSensorComponentEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace Unity.MLAgents.Editor
55
{
6-
[CustomEditor(typeof(CameraSensorComponent))]
6+
[CustomEditor(typeof(CameraSensorComponent), editorForChildClasses: true)]
77
[CanEditMultipleObjects]
88
internal class CameraSensorComponentEditor : UnityEditor.Editor
99
{

com.unity.ml-agents/Editor/GridSensorComponentEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Unity.MLAgents.Editor
66
{
7-
[CustomEditor(typeof(GridSensorComponent))]
7+
[CustomEditor(typeof(GridSensorComponent), editorForChildClasses: true)]
88
[CanEditMultipleObjects]
99
internal class GridSensorComponentEditor : UnityEditor.Editor
1010
{
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using UnityEditor;
2+
using Unity.MLAgents.Integrations.Match3;
3+
namespace Unity.MLAgents.Editor
4+
{
5+
[CustomEditor(typeof(Match3ActuatorComponent), editorForChildClasses: true)]
6+
[CanEditMultipleObjects]
7+
internal class Match3ActuatorComponentEditor : UnityEditor.Editor
8+
{
9+
public override void OnInspectorGUI()
10+
{
11+
var so = serializedObject;
12+
so.Update();
13+
14+
// Drawing the RenderTextureComponent
15+
EditorGUI.BeginChangeCheck();
16+
17+
EditorGUI.BeginDisabledGroup(!EditorUtilities.CanUpdateModelProperties());
18+
{
19+
EditorGUILayout.PropertyField(so.FindProperty("m_ActuatorName"), true);
20+
EditorGUILayout.PropertyField(so.FindProperty("m_RandomSeed"), true);
21+
}
22+
EditorGUI.EndDisabledGroup();
23+
EditorGUILayout.PropertyField(so.FindProperty("m_ForceHeuristic"), true);
24+
25+
var requireSensorUpdate = EditorGUI.EndChangeCheck();
26+
so.ApplyModifiedProperties();
27+
28+
if (requireSensorUpdate)
29+
{
30+
UpdateActuator();
31+
}
32+
}
33+
34+
void UpdateActuator()
35+
{
36+
}
37+
}
38+
}

com.unity.ml-agents/Editor/Match3ActuatorComponentEditor.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using UnityEditor;
2+
using Unity.MLAgents.Integrations.Match3;
3+
namespace Unity.MLAgents.Editor
4+
{
5+
[CustomEditor(typeof(Match3SensorComponent), editorForChildClasses: true)]
6+
[CanEditMultipleObjects]
7+
internal class Match3SensorComponentEditor : UnityEditor.Editor
8+
{
9+
public override void OnInspectorGUI()
10+
{
11+
var so = serializedObject;
12+
so.Update();
13+
14+
// Drawing the RenderTextureComponent
15+
EditorGUI.BeginChangeCheck();
16+
17+
EditorGUI.BeginDisabledGroup(!EditorUtilities.CanUpdateModelProperties());
18+
{
19+
EditorGUILayout.PropertyField(so.FindProperty("m_SensorName"), true);
20+
EditorGUILayout.PropertyField(so.FindProperty("m_ObservationType"), true);
21+
}
22+
EditorGUI.EndDisabledGroup();
23+
24+
var requireSensorUpdate = EditorGUI.EndChangeCheck();
25+
so.ApplyModifiedProperties();
26+
27+
if (requireSensorUpdate)
28+
{
29+
UpdateSensor();
30+
}
31+
}
32+
33+
void UpdateSensor()
34+
{
35+
}
36+
}
37+
}

com.unity.ml-agents/Editor/Match3SensorComponentEditor.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

com.unity.ml-agents/Editor/RayPerceptionSensorComponentBaseEditor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void UpdateSensorIfDirty()
8787
}
8888
}
8989

90-
[CustomEditor(typeof(RayPerceptionSensorComponent2D))]
90+
[CustomEditor(typeof(RayPerceptionSensorComponent2D), editorForChildClasses: true)]
9191
[CanEditMultipleObjects]
9292
internal class RayPerceptionSensorComponent2DEditor : RayPerceptionSensorComponentBaseEditor
9393
{
@@ -97,7 +97,7 @@ public override void OnInspectorGUI()
9797
}
9898
}
9999

100-
[CustomEditor(typeof(RayPerceptionSensorComponent3D))]
100+
[CustomEditor(typeof(RayPerceptionSensorComponent3D), editorForChildClasses: true)]
101101
[CanEditMultipleObjects]
102102
internal class RayPerceptionSensorComponent3DEditor : RayPerceptionSensorComponentBaseEditor
103103
{

0 commit comments

Comments
 (0)