Skip to content

Instantly share code, notes, and snippets.

@Josef212
Created August 6, 2020 08:39
Show Gist options
  • Save Josef212/d3beccc5721adfc66c4d4eaec906a301 to your computer and use it in GitHub Desktop.
Save Josef212/d3beccc5721adfc66c4d4eaec906a301 to your computer and use it in GitHub Desktop.
public class Helper
{
public static List<T> FindAssetsByType<T>() where T : UnityEngine.Object
{
List<T> assets = new List<T>();
string[] guids = AssetDatabase.FindAssets(string.Format("t:{0}", typeof(T)));
for( int i = 0; i < guids.Length; i++ )
{
string assetPath = AssetDatabase.GUIDToAssetPath( guids[i] );
T asset = AssetDatabase.LoadAssetAtPath<T>( assetPath );
if( asset != null )
{
assets.Add(asset);
}
}
return assets;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment