From 062a2507a8c2ada690cd10f4270c8b985e7a541b Mon Sep 17 00:00:00 2001 From: Zingabopp Date: Tue, 13 Oct 2020 20:38:16 -0500 Subject: [PATCH] Fixed Application.version being called too early --- IPA.Loader/Utilities/UnityGame.cs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/IPA.Loader/Utilities/UnityGame.cs b/IPA.Loader/Utilities/UnityGame.cs index e530328f..1edc5e4b 100644 --- a/IPA.Loader/Utilities/UnityGame.cs +++ b/IPA.Loader/Utilities/UnityGame.cs @@ -27,7 +27,27 @@ namespace IPA.Utilities _gameVersion = ver; Logging.Logger.log.Debug($"GameVersion set early to {ver}"); } - private static string ApplicationVersionProxy => Application.version; + private static string ApplicationVersionProxy + { + get + { + try + { + return Application.version; + } + catch(MissingMemberException ex) + { + Logging.Logger.log.Error($"Tried to grab 'Application.version' too early, it's probably broken now."); + Logging.Logger.log.Debug(ex); + } + catch (Exception ex) + { + Logging.Logger.log.Error($"Error getting Application.version: {ex.Message}"); + Logging.Logger.log.Debug(ex); + } + return string.Empty; + } + } internal static void EnsureRuntimeGameVersion() { try @@ -67,7 +87,7 @@ namespace IPA.Utilities /// if the curent thread is the Unity main thread, otherwise public static bool OnMainThread => Thread.CurrentThread.ManagedThreadId == mainThread?.ManagedThreadId; - internal static void SetMainThread() + internal static void SetMainThread() => mainThread = Thread.CurrentThread; ///