删除指定的组件
[MenuItem("Assets/Delete UIParticle")]
// 删除 UIParticle Component
private static void NewMenuOption()
{
var objs = Selection.objects;
foreach (var obj in objs)
{
GameObject go = AssetDatabase.LoadAssetAtPath<GameObject>(AssetDatabase.GetAssetPath(obj));
go.transform.GetChild(0).localScale *= go.GetComponent<UIParticle>().scale;
MonoBehaviour[] monoBehaviours = go.GetComponentsInChildren<MonoBehaviour>(true);
foreach (MonoBehaviour monoBehaviour in monoBehaviours)
{
if (monoBehaviour.GetType() == typeof(UIParticle))
{
GameObject.DestroyImmediate(monoBehaviour, true);
Debug.Log(go.name);
}
}
var renders = go.GetComponentsInChildren<ParticleSystemRenderer>();
foreach (var render in renders)
{
render.enabled = true;
}
//PrefabUtility.SetPropertyModifications(obj, new PropertyModification[0]);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
}