Skip to content

Commit

Permalink
Why didn't I commit this
Browse files Browse the repository at this point in the history
  • Loading branch information
xen-42 committed Nov 22, 2023
1 parent f581f50 commit 1106545
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
16 changes: 12 additions & 4 deletions Winch/Core/Initializer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using CommandTerminal;
using System;
using System.Net.Http;
using System.Text.RegularExpressions;
using UnityEngine;
Expand All @@ -15,12 +16,19 @@ internal static void Initialize()
{
WinchCore.Log.Debug("Initializer started.");

InitializeAssetLoader();
try
{
InitializeAssetLoader();

if(WinchConfig.GetProperty("EnableDeveloperConsole", false))
InitializeDevConsole();
if (WinchConfig.GetProperty("EnableDeveloperConsole", false))
InitializeDevConsole();

DredgeEvent.TriggerManagersLoaded();
DredgeEvent.TriggerManagersLoaded();
}
catch (Exception e)
{
WinchCore.Log.Error($"Failed to initialize mods {e}");
}
}

internal static void InitializePostUnityLoad()
Expand Down
19 changes: 18 additions & 1 deletion Winch/Patches/GameLoadPatcher.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
using HarmonyLib;
using System.CodeDom.Compiler;
using System.Threading;
using UnityEngine.Localization.Settings;
using Winch.Core;

namespace Winch.Patches
{

/// <summary>
/// Was on Wait for game managers or whatever before but that gives this error:
///
/*
Failed to initialize mods UnityEngine.UnityException: Internal_CreateGameObject can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
at(wrapper managed-to-native) UnityEngine.GameObject.Internal_CreateGameObject(UnityEngine.GameObject, string)
at UnityEngine.GameObject..ctor()[0x00008] in <fbf5779b092846b08cf20985bc90dcd0>:0
at Winch.Core.Initializer.InitializeAssetLoader() [0x00000] in C:\GitHub\Winch\Winch\Core\Initializer.cs:41
at Winch.Core.Initializer.Initialize() [0x0000f] in C:\GitHub\Winch\Winch\Core\Initializer.cs:21
*/
/// </summary>
[HarmonyPatch(typeof(GameManager))]
[HarmonyPatch(nameof(GameManager.WaitForAllAsyncManagers))]
[HarmonyPatch(nameof(GameManager.Start))]
class GameLoadPatcher
{
static void Postfix()
Expand Down

0 comments on commit 1106545

Please sign in to comment.