File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed
Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change 1- using System . Collections . Generic ;
1+ using System . Collections . Generic ;
22using System . Linq ;
33using UnityEngine ;
4+ #if UNITY_EDITOR && ODIN_INSPECTOR
5+ using Sirenix . Utilities . Editor ;
6+ #endif
47
58namespace ToolBox . Loader
69{
@@ -12,7 +15,7 @@ public static class Storage
1215 private static void Setup ( )
1316 {
1417#if UNITY_EDITOR
15- var assets = Resources . FindObjectsOfTypeAll < ScriptableObject > ( ) ;
18+ var assets = GetAssets ( ) ;
1619#else
1720 var assets = Resources . LoadAll < ScriptableObject > ( "" ) ;
1821#endif
@@ -25,7 +28,7 @@ public static T Get<T>() where T : ScriptableObject, ILoadable
2528 {
2629#if UNITY_EDITOR
2730 if ( ! Application . isPlaying )
28- _assets = Resources . FindObjectsOfTypeAll < ScriptableObject > ( ) ;
31+ _assets = GetAssets ( ) ;
2932#endif
3033
3134 for ( int i = 0 ; i < _assets . Length ; i ++ )
@@ -39,11 +42,22 @@ public static IEnumerable<T> GetAll<T>() where T : ScriptableObject, ILoadable
3942 {
4043#if UNITY_EDITOR
4144 if ( ! Application . isPlaying )
42- _assets = Resources . FindObjectsOfTypeAll < ScriptableObject > ( ) ;
45+ _assets = GetAssets ( ) ;
4346#endif
4447
4548 return _assets . Where ( a => a is T ) . Cast < T > ( ) ;
4649 }
50+
51+ private static ScriptableObject [ ] GetAssets ( )
52+ {
53+ #if ODIN_INSPECTOR
54+ var assets = AssetUtilities . GetAllAssetsOfType < ScriptableObject > ( ) . ToArray ( ) ;
55+ #else
56+ var assets = Resources . FindObjectsOfTypeAll < ScriptableObject > ( ) ;
57+ #endif
58+
59+ return assets ;
60+ }
4761 }
4862
4963 public interface ILoadable { }
You can’t perform that action at this time.
0 commit comments