diff --git a/TransparentWall/Plugin.cs b/TransparentWall/Plugin.cs index c91abcc..668c038 100644 --- a/TransparentWall/Plugin.cs +++ b/TransparentWall/Plugin.cs @@ -18,7 +18,7 @@ class Plugin : IEnhancedPlugin, IPlugin public string Version => VersionNum; public string[] Filter { get; } - private static AsyncScenesLoader loader; + private GameScenesManager _scenesManager; public const string KeyTranparentWall = "TransparentWall"; public const string KeyHMD = "HMD"; @@ -113,19 +113,22 @@ public void OnApplicationQuit() private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene scene) { - if (scene.name == "StandardLevelLoader") + if (_scenesManager == null) { - if (!loader) - loader = Resources.FindObjectsOfTypeAll().FirstOrDefault(); - loader.loadingDidFinishEvent += OnLoadingDidFinish; + _scenesManager = Resources.FindObjectsOfTypeAll().FirstOrDefault(); + + if (_scenesManager != null) + _scenesManager.transitionDidFinishEvent += SceneTransitionDidFinish; } } - public void OnLoadingDidFinish() + + private void SceneTransitionDidFinish() { - new GameObject("TransparentWall").AddComponent(); + if (SceneManager.GetActiveScene().name == "GameCore") + new GameObject("TransparentWall").AddComponent(); } - public void OnLateUpdate() + public void OnLateUpdate() { } diff --git a/TransparentWall/TransparentWall.cs b/TransparentWall/TransparentWall.cs index dfb681a..f44158f 100644 --- a/TransparentWall/TransparentWall.cs +++ b/TransparentWall/TransparentWall.cs @@ -56,10 +56,11 @@ private IEnumerator setupCamerasCoroutine() { yield return new WaitForEndOfFrame(); - var mainGameSceneSetupData = Resources.FindObjectsOfTypeAll().FirstOrDefault(); + StandardLevelSceneSetupDataSO levelSetup = Resources.FindObjectsOfTypeAll().FirstOrDefault(); Camera mainCamera = FindObjectsOfType().FirstOrDefault(x => x.CompareTag("MainCamera")); - if (Plugin.IsHMDOn && !mainGameSceneSetupData.gameplayOptions.validForScoreUse) + + if (Plugin.IsHMDOn && levelSetup.gameplayCoreSetupData.gameplayModifiers.noFail) mainCamera.cullingMask &= ~(1 << WallLayer); else mainCamera.cullingMask |= (1 << WallLayer);