Skip to content

Commit 7ef256c

Browse files
authored
Update Storage.cs
1 parent 3ef6c81 commit 7ef256c

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

Runtime/Storage.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
using System.Linq;
33
using UnityEngine;
4+
#if UNITY_EDITOR && ODIN_INSPECTOR
5+
using Sirenix.Utilities.Editor;
6+
#endif
47

58
namespace 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 { }

0 commit comments

Comments
 (0)