From 0aa89efdd14d725811f6a03962f46060198e2f38 Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Tue, 21 Sep 2021 16:26:41 +0900 Subject: [PATCH] refactor: refactor editor --- Scripts/Editor/UIParticleEditor.cs | 38 +++++++++++++----------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/Scripts/Editor/UIParticleEditor.cs b/Scripts/Editor/UIParticleEditor.cs index 6e08d35..0018881 100644 --- a/Scripts/Editor/UIParticleEditor.cs +++ b/Scripts/Editor/UIParticleEditor.cs @@ -23,11 +23,10 @@ namespace Coffee.UIExtensions private static readonly GUIContent s_Content3D = new GUIContent("3D"); private static readonly GUIContent s_ContentScale = new GUIContent("Scale"); - private SerializedProperty _spMaskable; - private SerializedProperty _spScale; - private SerializedProperty _spAnimatableProperties; - private SerializedProperty _spShrinkByMaterial; - + private SerializedProperty m_Maskable; + private SerializedProperty m_Scale3D; + private SerializedProperty m_AnimatableProperties; + private SerializedProperty m_ShrinkByMaterial; private ReorderableList _ro; private bool _xyzMode; @@ -51,11 +50,10 @@ namespace Coffee.UIExtensions protected override void OnEnable() { base.OnEnable(); - _spMaskable = serializedObject.FindProperty("m_Maskable"); - _spScale = serializedObject.FindProperty("m_Scale3D"); - _spAnimatableProperties = serializedObject.FindProperty("m_AnimatableProperties"); - _spShrinkByMaterial = serializedObject.FindProperty("m_ShrinkByMaterial"); - _showMaterials = EditorPrefs.GetBool("Coffee.UIExtensions.UIParticleEditor._showMaterials", true); + m_Maskable = serializedObject.FindProperty("m_Maskable"); + m_Scale3D = serializedObject.FindProperty("m_Scale3D"); + m_AnimatableProperties = serializedObject.FindProperty("m_AnimatableProperties"); + m_ShrinkByMaterial = serializedObject.FindProperty("m_ShrinkByMaterial"); var sp = serializedObject.FindProperty("m_Particles"); _ro = new ReorderableList(sp.serializedObject, sp, true, true, true, true) @@ -128,10 +126,10 @@ namespace Coffee.UIExtensions serializedObject.Update(); // Maskable - EditorGUILayout.PropertyField(_spMaskable); + EditorGUILayout.PropertyField(m_Maskable); // Scale - _xyzMode = DrawFloatOrVector3Field(_spScale, _xyzMode); + _xyzMode = DrawFloatOrVector3Field(m_Scale3D, _xyzMode); // AnimatableProperties var mats = current.particles @@ -142,15 +140,15 @@ namespace Coffee.UIExtensions // Animated properties EditorGUI.BeginChangeCheck(); - AnimatedPropertiesEditor.DrawAnimatableProperties(_spAnimatableProperties, mats); + AnimatedPropertiesEditor.DrawAnimatableProperties(m_AnimatableProperties, mats); if (EditorGUI.EndChangeCheck()) { - foreach (UIParticle t in targets) - t.SetMaterialDirty(); + // foreach (UIParticle t in targets) + // t.SetMaterialDirty(); } // ShrinkByMaterial - EditorGUILayout.PropertyField(_spShrinkByMaterial); + EditorGUILayout.PropertyField(m_ShrinkByMaterial); // Target ParticleSystems. _ro.DoLayoutList(); @@ -174,16 +172,14 @@ namespace Coffee.UIExtensions } } - // Does the shader support UI masks? - + // UIParticle for trail should be removed. if (FixButton(current.m_IsTrail, "This UIParticle component should be removed. The UIParticle for trails is no longer needed.")) { DestroyUIParticle(current); - return; } } - void DestroyUIParticle(UIParticle p, bool ignoreCurrent = false) + private void DestroyUIParticle(UIParticle p, bool ignoreCurrent = false) { if (!p || ignoreCurrent && target == p) return; @@ -205,7 +201,7 @@ namespace Coffee.UIExtensions #endif } - bool FixButton(bool show, string text) + private static bool FixButton(bool show, string text) { if (!show) return false; using (new EditorGUILayout.HorizontalScope(GUILayout.ExpandWidth(true)))