53 lines
1.8 KiB
C#
53 lines
1.8 KiB
C#
using UnityEditor;
|
|
using UnityEditor.SceneManagement;
|
|
using UnityEngine;
|
|
public static class MeshToolForParticle
|
|
{
|
|
[MenuItem("Tools/ParticleSystem/FindScenes", false, 20)]
|
|
public static void FindScenes()
|
|
{
|
|
var guids = AssetDatabase.FindAssets("t:Scene");
|
|
foreach (var guid in guids)
|
|
{
|
|
string path = AssetDatabase.GUIDToAssetPath(guid);
|
|
var scene = EditorSceneManager.OpenScene(path, OpenSceneMode.Single);
|
|
var roots = scene.GetRootGameObjects();
|
|
bool found = false;
|
|
foreach (var go in roots)
|
|
{
|
|
found |= Find(go);
|
|
}
|
|
if (found)
|
|
{
|
|
Debug.Log(path);
|
|
}
|
|
}
|
|
}
|
|
[MenuItem("Tools/ParticleSystem/FindPrefabs", false, 20)]
|
|
public static void FindPrefabs()
|
|
{
|
|
var guids = AssetDatabase.FindAssets("t:Prefab");
|
|
foreach (var guid in guids)
|
|
{
|
|
string path = AssetDatabase.GUIDToAssetPath(guid);
|
|
var prefab = AssetDatabase.LoadAssetAtPath<GameObject>(path);
|
|
Find(prefab);
|
|
}
|
|
}
|
|
private static bool Find(GameObject go)
|
|
{
|
|
bool found = false;
|
|
var particles = go.GetComponentsInChildren<ParticleSystem>(true);
|
|
foreach (var particle in particles)
|
|
{
|
|
if (particle.shape.enabled && particle.shape.shapeType == ParticleSystemShapeType.Mesh &&
|
|
particle.shape.meshShapeType != ParticleSystemMeshShapeType.Vertex)
|
|
{
|
|
string prefabPath = PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot(particle);
|
|
Debug.LogWarning(string.Format("Path: {0}\nGo: {1}", prefabPath, particle.gameObject.name));
|
|
found = true;
|
|
}
|
|
}
|
|
return found;
|
|
}
|
|
} |