From d9eb91c12013dcb56be145f95fa0f3f76b3e461e Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Fri, 19 Feb 2021 09:57:02 +0900 Subject: [PATCH] refactor: modify the value when the field is changed --- Scripts/Editor/UIParticleEditor.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Scripts/Editor/UIParticleEditor.cs b/Scripts/Editor/UIParticleEditor.cs index 0afe59e..e227145 100644 --- a/Scripts/Editor/UIParticleEditor.cs +++ b/Scripts/Editor/UIParticleEditor.cs @@ -250,20 +250,27 @@ namespace Coffee.UIExtensions EditorGUILayout.BeginHorizontal(); if (showXyz) { + EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(sp); + if (EditorGUI.EndChangeCheck()) + { + x.floatValue = Mathf.Max(0.001f, x.floatValue); + y.floatValue = Mathf.Max(0.001f, y.floatValue); + z.floatValue = Mathf.Max(0.001f, z.floatValue); + } } else { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(x, s_ContentScale); if (EditorGUI.EndChangeCheck()) - z.floatValue = y.floatValue = x.floatValue; + { + x.floatValue = Mathf.Max(0.001f, x.floatValue); + y.floatValue = Mathf.Max(0.001f, x.floatValue); + z.floatValue = Mathf.Max(0.001f, x.floatValue); + } } - if (x.floatValue < 0.001f) x.floatValue = 0.001f; - if (y.floatValue < 0.001f) y.floatValue = 0.001f; - if (z.floatValue < 0.001f) z.floatValue = 0.001f; - EditorGUI.BeginChangeCheck(); showXyz = GUILayout.Toggle(showXyz, s_Content3D, EditorStyles.miniButton, GUILayout.Width(30)); if (EditorGUI.EndChangeCheck() && !showXyz)