From 3f929b64b416d544e8902d08eb8bf66831772316 Mon Sep 17 00:00:00 2001 From: Nicolas Gnyra Date: Fri, 22 Mar 2024 18:39:27 -0400 Subject: [PATCH] Fix potential weird exceptions on shutdown --- BeatSaberMarkupLanguage/BSMLParser.cs | 17 +++++++++++++++++ .../BeatSaberMarkupLanguage.csproj | 14 ++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/BeatSaberMarkupLanguage/BSMLParser.cs b/BeatSaberMarkupLanguage/BSMLParser.cs index ef0ca4b3..0bf589fa 100644 --- a/BeatSaberMarkupLanguage/BSMLParser.cs +++ b/BeatSaberMarkupLanguage/BSMLParser.cs @@ -12,6 +12,9 @@ using BeatSaberMarkupLanguage.TypeHandlers; using BeatSaberMarkupLanguage.Util; using UnityEngine; +using UnityEngine.AddressableAssets; +using UnityEngine.ResourceManagement.AsyncOperations; +using UnityEngine.ResourceManagement.ResourceProviders; using Zenject; namespace BeatSaberMarkupLanguage @@ -118,6 +121,11 @@ public BSMLParserParams Parse(string content, GameObject parent, object host = n public BSMLParserParams Parse(XmlNode parentNode, GameObject parent, object host = null) { + if (!IsMainMenuSceneLoaded()) + { + return null; + } + BSMLParserParams parserParams = new(host); FieldAccessOption fieldAccessOptions = FieldAccessOption.Auto; @@ -450,6 +458,15 @@ private Dictionary GetParameters(XmlNode node, Dictionary ((SceneInstance)si.Result).Scene.name == "MainMenu"); + return instance.IsValid() && ((SceneProvider.SceneOp)instance.m_InternalOp).m_DepOp.Result.Select(op => op.Result).OfType().All(ab => ab.m_AssetBundle != null); + } + public struct ComponentTypeWithData { public TypeHandler typeHandler; diff --git a/BeatSaberMarkupLanguage/BeatSaberMarkupLanguage.csproj b/BeatSaberMarkupLanguage/BeatSaberMarkupLanguage.csproj index a0d3d26d..914b673a 100644 --- a/BeatSaberMarkupLanguage/BeatSaberMarkupLanguage.csproj +++ b/BeatSaberMarkupLanguage/BeatSaberMarkupLanguage.csproj @@ -70,6 +70,10 @@ False True + + $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.AssetBundleModule.dll + False + $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll False @@ -108,6 +112,16 @@ $(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UnityWebRequestModule.dll False + + $(BeatSaberDir)\Beat Saber_Data\Managed\Unity.Addressables.dll + False + True + + + $(BeatSaberDir)\Beat Saber_Data\Managed\Unity.ResourceManager.dll + False + True + $(BeatSaberDir)\Beat Saber_Data\Managed\VRUI.dll False