Skip to content

Commit dcb1e06

Browse files
authored
Update Storage.cs
1 parent c341934 commit dcb1e06

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

Runtime/Storage.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Diagnostics;
43
using System.Linq;
54
#if UNITY_EDITOR
65
using ToolBox.Loader.Editor;
@@ -55,27 +54,25 @@ public static IEnumerable<T> GetAll<T>() where T : ScriptableObject, ILoadable
5554
#if UNITY_EDITOR
5655
private static void LoadAssetsInEditor()
5756
{
58-
_loadables = EditorStorage.
59-
GetAllAssetsOfType<ScriptableObject>().
60-
Where(x => x is ILoadable).
61-
Cast<ILoadable>().
62-
ToArray();
57+
_loadables = EditorStorage
58+
.GetAllAssetsOfType<ScriptableObject>()
59+
.OfType<ILoadable>()
60+
.ToArray();
6361
}
6462

6563
internal void LoadAssets()
6664
{
67-
// I don't know why but if you don't select this asset before building, array will be empty in build
68-
Selection.activeObject = this;
69-
7065
var assets = EditorStorage.GetAllAssetsOfType<ScriptableObject>();
71-
var loadables = assets.Where(x => x is ILoadable).ToArray();
72-
var initializables = assets.Where(x => x is IInitializableBeforeBuild).Cast<IInitializableBeforeBuild>();
66+
var loadables = assets.OfType<ILoadable>().ToArray();
67+
var initializables = assets.OfType<IInitializableBeforeBuild>();
7368

7469
_assets = new ScriptableObject[loadables.Length];
7570
Array.Copy(loadables, _assets, loadables.Length);
7671

7772
foreach (var initializable in initializables)
7873
initializable.Init();
74+
75+
EditorUtility.SetDirty(this);
7976
}
8077
#endif
8178
}

0 commit comments

Comments
 (0)