diff --git a/Packages/UIParticle/Scripts/Editor/AnimatedPropertiesEditor.cs b/Packages/UIParticle/Scripts/Editor/AnimatedPropertiesEditor.cs index 6e2660d..6e598cd 100644 --- a/Packages/UIParticle/Scripts/Editor/AnimatedPropertiesEditor.cs +++ b/Packages/UIParticle/Scripts/Editor/AnimatedPropertiesEditor.cs @@ -1,3 +1,4 @@ +using System; using UnityEditor; using UnityEngine; using System.Collections.Generic; @@ -8,8 +9,9 @@ namespace Coffee.UIExtensions { internal class AnimatedPropertiesEditor { - static readonly List s_ActiveNames = new List(); - static readonly System.Text.StringBuilder s_Sb = new System.Text.StringBuilder(); + private static readonly List s_ActiveNames = new List(); + private static readonly System.Text.StringBuilder s_Sb = new System.Text.StringBuilder(); + private static readonly HashSet s_Names = new HashSet(); private string _name; private ShaderPropertyType _type; @@ -39,10 +41,8 @@ static string CollectActiveNames(SerializedProperty sp, List result) return s_Sb.ToString(); } - public static void DrawAnimatableProperties(SerializedProperty sp, Material mat) + public static void DrawAnimatableProperties(SerializedProperty sp, Material[] mats) { - if (!mat || !mat.shader) return; - bool isClicked; using (new EditorGUILayout.HorizontalScope(GUILayout.ExpandWidth(false))) { @@ -72,17 +72,27 @@ public static void DrawAnimatableProperties(SerializedProperty sp, Material mat) } } - for (var i = 0; i < ShaderUtil.GetPropertyCount(mat.shader); i++) + s_Names.Clear(); + foreach (var mat in mats) { - var pName = ShaderUtil.GetPropertyName(mat.shader, i); - var type = (ShaderPropertyType) ShaderUtil.GetPropertyType(mat.shader, i); - AddMenu(gm, sp, new AnimatedPropertiesEditor {_name = pName, _type = type}, true); + if (!mat || !mat.shader) continue; + + for (var i = 0; i < ShaderUtil.GetPropertyCount(mat.shader); i++) + { + var pName = ShaderUtil.GetPropertyName(mat.shader, i); + var type = (ShaderPropertyType) ShaderUtil.GetPropertyType(mat.shader, i); + var name = string.Format("{0} ({1})", pName, type); + if (s_Names.Contains(name)) continue; + s_Names.Add(name); - if (type != ShaderPropertyType.Texture) continue; + AddMenu(gm, sp, new AnimatedPropertiesEditor {_name = pName, _type = type}, true); - AddMenu(gm, sp, new AnimatedPropertiesEditor {_name = pName + "_ST", _type = ShaderPropertyType.Vector}, true); - AddMenu(gm, sp, new AnimatedPropertiesEditor {_name = pName + "_HDR", _type = ShaderPropertyType.Vector}, true); - AddMenu(gm, sp, new AnimatedPropertiesEditor {_name = pName + "_TexelSize", _type = ShaderPropertyType.Vector}, true); + if (type != ShaderPropertyType.Texture) continue; + + AddMenu(gm, sp, new AnimatedPropertiesEditor {_name = pName + "_ST", _type = ShaderPropertyType.Vector}, true); + AddMenu(gm, sp, new AnimatedPropertiesEditor {_name = pName + "_HDR", _type = ShaderPropertyType.Vector}, true); + AddMenu(gm, sp, new AnimatedPropertiesEditor {_name = pName + "_TexelSize", _type = ShaderPropertyType.Vector}, true); + } } gm.ShowAsContext(); diff --git a/Packages/UIParticle/Scripts/Editor/UIParticleEditor.cs b/Packages/UIParticle/Scripts/Editor/UIParticleEditor.cs index 921c351..2512285 100644 --- a/Packages/UIParticle/Scripts/Editor/UIParticleEditor.cs +++ b/Packages/UIParticle/Scripts/Editor/UIParticleEditor.cs @@ -2,6 +2,7 @@ using UnityEditor.UI; using UnityEngine; using System.Collections.Generic; +using System.Linq; using UnityEditorInternal; using UnityEngine.UI; @@ -100,7 +101,12 @@ public override void OnInspectorGUI() EditorGUILayout.PropertyField(_spScale); // AnimatableProperties - AnimatedPropertiesEditor.DrawAnimatableProperties(_spAnimatableProperties, current.material); + var mats = current.particles + .Where(x => x) + .Select(x => x.GetComponent().sharedMaterial) + .Where(x => x) + .ToArray(); + AnimatedPropertiesEditor.DrawAnimatableProperties(_spAnimatableProperties, mats); _ro.DoLayoutList();