refactor: refactor editor

pull/197/head
mob-sakai 2021-09-21 16:26:41 +09:00
parent b743dfb8b4
commit 0aa89efdd1
1 changed files with 17 additions and 21 deletions

View File

@ -23,11 +23,10 @@ namespace Coffee.UIExtensions
private static readonly GUIContent s_Content3D = new GUIContent("3D"); private static readonly GUIContent s_Content3D = new GUIContent("3D");
private static readonly GUIContent s_ContentScale = new GUIContent("Scale"); private static readonly GUIContent s_ContentScale = new GUIContent("Scale");
private SerializedProperty _spMaskable; private SerializedProperty m_Maskable;
private SerializedProperty _spScale; private SerializedProperty m_Scale3D;
private SerializedProperty _spAnimatableProperties; private SerializedProperty m_AnimatableProperties;
private SerializedProperty _spShrinkByMaterial; private SerializedProperty m_ShrinkByMaterial;
private ReorderableList _ro; private ReorderableList _ro;
private bool _xyzMode; private bool _xyzMode;
@ -51,11 +50,10 @@ namespace Coffee.UIExtensions
protected override void OnEnable() protected override void OnEnable()
{ {
base.OnEnable(); base.OnEnable();
_spMaskable = serializedObject.FindProperty("m_Maskable"); m_Maskable = serializedObject.FindProperty("m_Maskable");
_spScale = serializedObject.FindProperty("m_Scale3D"); m_Scale3D = serializedObject.FindProperty("m_Scale3D");
_spAnimatableProperties = serializedObject.FindProperty("m_AnimatableProperties"); m_AnimatableProperties = serializedObject.FindProperty("m_AnimatableProperties");
_spShrinkByMaterial = serializedObject.FindProperty("m_ShrinkByMaterial"); m_ShrinkByMaterial = serializedObject.FindProperty("m_ShrinkByMaterial");
_showMaterials = EditorPrefs.GetBool("Coffee.UIExtensions.UIParticleEditor._showMaterials", true);
var sp = serializedObject.FindProperty("m_Particles"); var sp = serializedObject.FindProperty("m_Particles");
_ro = new ReorderableList(sp.serializedObject, sp, true, true, true, true) _ro = new ReorderableList(sp.serializedObject, sp, true, true, true, true)
@ -128,10 +126,10 @@ namespace Coffee.UIExtensions
serializedObject.Update(); serializedObject.Update();
// Maskable // Maskable
EditorGUILayout.PropertyField(_spMaskable); EditorGUILayout.PropertyField(m_Maskable);
// Scale // Scale
_xyzMode = DrawFloatOrVector3Field(_spScale, _xyzMode); _xyzMode = DrawFloatOrVector3Field(m_Scale3D, _xyzMode);
// AnimatableProperties // AnimatableProperties
var mats = current.particles var mats = current.particles
@ -142,15 +140,15 @@ namespace Coffee.UIExtensions
// Animated properties // Animated properties
EditorGUI.BeginChangeCheck(); EditorGUI.BeginChangeCheck();
AnimatedPropertiesEditor.DrawAnimatableProperties(_spAnimatableProperties, mats); AnimatedPropertiesEditor.DrawAnimatableProperties(m_AnimatableProperties, mats);
if (EditorGUI.EndChangeCheck()) if (EditorGUI.EndChangeCheck())
{ {
foreach (UIParticle t in targets) // foreach (UIParticle t in targets)
t.SetMaterialDirty(); // t.SetMaterialDirty();
} }
// ShrinkByMaterial // ShrinkByMaterial
EditorGUILayout.PropertyField(_spShrinkByMaterial); EditorGUILayout.PropertyField(m_ShrinkByMaterial);
// Target ParticleSystems. // Target ParticleSystems.
_ro.DoLayoutList(); _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.")) if (FixButton(current.m_IsTrail, "This UIParticle component should be removed. The UIParticle for trails is no longer needed."))
{ {
DestroyUIParticle(current); DestroyUIParticle(current);
return;
} }
} }
void DestroyUIParticle(UIParticle p, bool ignoreCurrent = false) private void DestroyUIParticle(UIParticle p, bool ignoreCurrent = false)
{ {
if (!p || ignoreCurrent && target == p) return; if (!p || ignoreCurrent && target == p) return;
@ -205,7 +201,7 @@ namespace Coffee.UIExtensions
#endif #endif
} }
bool FixButton(bool show, string text) private static bool FixButton(bool show, string text)
{ {
if (!show) return false; if (!show) return false;
using (new EditorGUILayout.HorizontalScope(GUILayout.ExpandWidth(true))) using (new EditorGUILayout.HorizontalScope(GUILayout.ExpandWidth(true)))