-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEditorUtilities.cs
More file actions
36 lines (30 loc) · 851 Bytes
/
EditorUtilities.cs
File metadata and controls
36 lines (30 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#if UNITY_EDITOR
//Author: João Azuaga
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
namespace razveck.UnityUtility {
public static class EditorUtilities {
public static T LoadAssetOfType<T>() where T : UnityEngine.Object {
Type t = typeof(T);
Debug.Log(t);
T result = AssetDatabase.FindAssets($"t:{t}")
.Select(x => AssetDatabase.GUIDToAssetPath(x))
.Select(x => AssetDatabase.LoadAssetAtPath<T>(x))
.First();
return result;
}
public static List<T> LoadAssetsOfType<T>() where T : UnityEngine.Object {
Type t = typeof(T);
Debug.Log(t);
List<T> result = AssetDatabase.FindAssets($"t:{t}")
.Select(x => AssetDatabase.GUIDToAssetPath(x))
.Select(x => AssetDatabase.LoadAssetAtPath<T>(x))
.ToList();
return result;
}
}
}
#endif