public static List<T> GetAssetsWithScript<T>(string path) where T:MonoBehaviour
{
T tmp;
string assetPath;
GameObject asset;
List<T> assetList = new List<T> ();
string[] guids = AssetDatabase.FindAssets ("t:Prefab", new string[] {path});
for (int i = ; i < guids.Length; i++)
{
assetPath = AssetDatabase.GUIDToAssetPath (guids[i]);
asset = AssetDatabase.LoadAssetAtPath(assetPath, typeof(GameObject)) as GameObject;
tmp = asset.GetComponent<T> ();
if (tmp != null)
{
assetList.Add (tmp);
}
}
return assetList;
}
05-04 06:10