Created
March 23, 2020 01:28
-
-
Save baba-s/1e60664c6de275d8dc2232af6803d61b 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
using System.Collections.Generic; | |
using System.Linq; | |
using UnityEditor; | |
public static class AssetDatabaseUtils | |
{ | |
public static T FindAsset<T>() where T : UnityEngine.Object | |
{ | |
return FindAssets<T>().FirstOrDefault(); | |
} | |
public static IEnumerable<T> FindAssets<T>() where T : UnityEngine.Object | |
{ | |
return AssetDatabase | |
.FindAssets( $"t:{typeof( T ).Name}" ) | |
.Select( c => AssetDatabase.GUIDToAssetPath( c ) ) | |
.Select( c => AssetDatabase.LoadAssetAtPath<T>( c ) ) | |
; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment