Created
August 6, 2020 08:39
-
-
Save Josef212/d3beccc5721adfc66c4d4eaec906a301 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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