diff --git a/MonkeyLoader.Unity.Integration/UnityHooks.cs b/MonkeyLoader.Unity.Integration/UnityHooks.cs index 2163dcf..6c1089d 100644 --- a/MonkeyLoader.Unity.Integration/UnityHooks.cs +++ b/MonkeyLoader.Unity.Integration/UnityHooks.cs @@ -15,8 +15,19 @@ internal sealed class UnityHooks : Monkey { public override string Name { get; } = "Unity Hooks"; - private static IEnumerable UnityMonkeys - => Mod.Loader.Monkeys.SelectCastable(); + private static IUnityMonkeyInternal[] UnityMonkeys + { + get + { + var monkeys = Mod.Loader.Monkeys + .SelectCastable() + .ToArray(); + + Array.Sort(monkeys, Monkey.AscendingComparer); + + return monkeys; + } + } protected override IEnumerable GetFeaturePatches() => Enumerable.Empty(); @@ -32,14 +43,14 @@ private void SceneManager_sceneLoaded(Scene scene, LoadSceneMode sceneMode) { Info(() => "First Scene Loaded! Executing OnFirstSceneReady hooks on UnityMonkeys!"); - var unityMonkeys = UnityMonkeys.ToArray(); + var unityMonkeys = UnityMonkeys; Logger.Trace(() => "Running FirstSceneReady hooks in this order:"); Logger.Trace(unityMonkeys.Select(uM => new Func(() => $"{uM.Mod.Title}/{uM.Name}"))); SceneManager.sceneLoaded -= SceneManager_sceneLoaded; var sw = Stopwatch.StartNew(); - foreach (var unityMonkey in UnityMonkeys) + foreach (var unityMonkey in unityMonkeys) unityMonkey.FirstSceneReady(scene); Info(() => $"Done executing OnFirstSceneReady hooks on UnityMonkeys in {sw.ElapsedMilliseconds}ms!");