Skip to content

Commit d9eb91c

Browse files
authored
refactor: modify the value when the field is changed
1 parent 13223b2 commit d9eb91c

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Scripts/Editor/UIParticleEditor.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,20 +250,27 @@ private static bool DrawFloatOrVector3Field(SerializedProperty sp, bool showXyz)
250250
EditorGUILayout.BeginHorizontal();
251251
if (showXyz)
252252
{
253+
EditorGUI.BeginChangeCheck();
253254
EditorGUILayout.PropertyField(sp);
255+
if (EditorGUI.EndChangeCheck())
256+
{
257+
x.floatValue = Mathf.Max(0.001f, x.floatValue);
258+
y.floatValue = Mathf.Max(0.001f, y.floatValue);
259+
z.floatValue = Mathf.Max(0.001f, z.floatValue);
260+
}
254261
}
255262
else
256263
{
257264
EditorGUI.BeginChangeCheck();
258265
EditorGUILayout.PropertyField(x, s_ContentScale);
259266
if (EditorGUI.EndChangeCheck())
260-
z.floatValue = y.floatValue = x.floatValue;
267+
{
268+
x.floatValue = Mathf.Max(0.001f, x.floatValue);
269+
y.floatValue = Mathf.Max(0.001f, x.floatValue);
270+
z.floatValue = Mathf.Max(0.001f, x.floatValue);
271+
}
261272
}
262273

263-
if (x.floatValue < 0.001f) x.floatValue = 0.001f;
264-
if (y.floatValue < 0.001f) y.floatValue = 0.001f;
265-
if (z.floatValue < 0.001f) z.floatValue = 0.001f;
266-
267274
EditorGUI.BeginChangeCheck();
268275
showXyz = GUILayout.Toggle(showXyz, s_Content3D, EditorStyles.miniButton, GUILayout.Width(30));
269276
if (EditorGUI.EndChangeCheck() && !showXyz)

0 commit comments

Comments
 (0)