using UnityEditor; using UnityEngine; using UIExtensions; public class UIParticleAdd { [MenuItem("GameObject/UIParticleAdd", false, 22)] public static void AddUIParticle() { GameObject go = Selection.activeGameObject; ParticleSystem[] array = go.GetComponentsInChildren(); for (int i = 0; i < array.Length; ++i) { GameObject obj = array[i].gameObject; if (obj.GetComponent() == null) ObjectFactory.AddComponent(obj); UIParticle particle = obj.GetComponent() == null ? obj.AddComponent() : obj.GetComponent(); particle.cachedParticleSystem = array[i]; if (i == 0) { UINode node = obj.GetComponent() == null ? obj.AddComponent() : obj.GetComponent(); node.UIName = go.name.ToLower(); } } EditorUtility.SetDirty(go); } }