Created
November 2, 2019 23:15
-
-
Save CapitanLiteral/f2cf9166e07e99f4114709da2a46ccf4 to your computer and use it in GitHub Desktop.
This file contains 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 static List<T> FindAssetsByType<T>() where T : 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