From 51aa9256a6bc33d4518a88811d168008d6bb5404 Mon Sep 17 00:00:00 2001 From: Aeroluna <40481393+Aeroluna@users.noreply.github.com> Date: Tue, 28 Jan 2025 13:00:49 -0700 Subject: [PATCH] dont run OnEnable until injected fixes #5 --- Vivify/Controllers/CameraPropertyController.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Vivify/Controllers/CameraPropertyController.cs b/Vivify/Controllers/CameraPropertyController.cs index fa317e2..b72a2c6 100644 --- a/Vivify/Controllers/CameraPropertyController.cs +++ b/Vivify/Controllers/CameraPropertyController.cs @@ -14,6 +14,8 @@ namespace Vivify.Controllers; [RequireComponent(typeof(Camera))] internal class CameraPropertyController : MonoBehaviour { + private bool _injected; + private Camera _camera = null!; private DepthTextureMode _cachedDepthTextureMode; private CameraClearFlags _cachedClearFlags; @@ -115,6 +117,11 @@ private void Construct( SettingsManager settingsManager) { _settingsManager = settingsManager; + _injected = true; + if (isActiveAndEnabled) + { + OnEnable(); + } } #endif @@ -132,6 +139,11 @@ private void Awake() private void OnEnable() { + if (!_injected) + { + return; + } + _cachedDepthTextureMode = _camera.depthTextureMode; _cachedClearFlags = _camera.clearFlags; _cachedBackgroundColor = _camera.backgroundColor;