Skip to content

Commit 623fd14

Browse files
authored
Fix #3932, stop the editor from going into a loop when a prefab is selected. (#3949)
1 parent 266a53a commit 623fd14

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,14 @@ static void DrawVectorAction(Rect position, SerializedProperty property)
124124
static void DrawContinuousVectorAction(Rect position, SerializedProperty property)
125125
{
126126
var vecActionSize = property.FindPropertyRelative(k_ActionSizePropName);
127-
vecActionSize.arraySize = 1;
127+
128+
// This check is here due to:
129+
// https://fogbugz.unity3d.com/f/cases/1246524/
130+
// If this case has been resolved, please remove this if condition.
131+
if (vecActionSize.arraySize != 1)
132+
{
133+
vecActionSize.arraySize = 1;
134+
}
128135
var continuousActionSize =
129136
vecActionSize.GetArrayElementAtIndex(0);
130137
EditorGUI.PropertyField(
@@ -142,8 +149,17 @@ static void DrawContinuousVectorAction(Rect position, SerializedProperty propert
142149
static void DrawDiscreteVectorAction(Rect position, SerializedProperty property)
143150
{
144151
var vecActionSize = property.FindPropertyRelative(k_ActionSizePropName);
145-
vecActionSize.arraySize = EditorGUI.IntField(
152+
var newSize = EditorGUI.IntField(
146153
position, "Branches Size", vecActionSize.arraySize);
154+
155+
// This check is here due to:
156+
// https://fogbugz.unity3d.com/f/cases/1246524/
157+
// If this case has been resolved, please remove this if condition.
158+
if (newSize != vecActionSize.arraySize)
159+
{
160+
vecActionSize.arraySize = newSize;
161+
}
162+
147163
position.y += k_LineHeight;
148164
position.x += 20;
149165
position.width -= 20;

0 commit comments

Comments
 (0)