From 8c2c06aff410eb75c6c5ab4cbd1137254aa9aa3d Mon Sep 17 00:00:00 2001 From: originalnicodr Date: Fri, 20 Jun 2025 18:08:15 -0300 Subject: [PATCH] Replaced Array.IndexOf by a manual iteration because it wasn't working for some reason. Also polished some vertical spaces. --- src/UI/Panels/FreeCamPanel.cs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/UI/Panels/FreeCamPanel.cs b/src/UI/Panels/FreeCamPanel.cs index f0aaf1c..f32c10b 100644 --- a/src/UI/Panels/FreeCamPanel.cs +++ b/src/UI/Panels/FreeCamPanel.cs @@ -138,10 +138,9 @@ namespace UnityExplorer.UI.Panels private static Camera GetTargetCamera() { - Camera currentMain = Camera.main; if (!ConfigManager.Advanced_Freecam_Selection.Value && !targetCameraDropdown) { - return currentMain; + return Camera.main; } Camera[] cameras = GetAvailableCameras(); @@ -166,7 +165,14 @@ namespace UnityExplorer.UI.Panels // If couldn't find the user selected camera default to the main camera if (selectedCameraTargetIndex == -1) { - selectedCameraTargetIndex = Array.IndexOf(cameras, Camera.main); + for (int i = 0; i < cameras.Length; i++) + { + if (cameras[i] == Camera.main) + { + selectedCameraTargetIndex = i; + break; + } + } } SetTargetDropdownValueWithoutNotify(selectedCameraTargetIndex); @@ -327,12 +333,6 @@ namespace UnityExplorer.UI.Panels internal static void EndFreecam() { - if (ourCamera == null) - { - ExplorerCore.LogWarning("EndFreecam called but ourCamera is null, returning."); - return; - } - inFreeCamMode = false; connector?.UpdateFreecamStatus(false); @@ -363,8 +363,8 @@ namespace UnityExplorer.UI.Panels MaybeToggleOrthographic(true); ToggleCustomComponents(true); MethodInfo resetCullingMatrixMethod = typeof(Camera).GetMethod("ResetCullingMatrix", new Type[] {}); - resetCullingMatrixMethod.Invoke(ourCamera, null); + ourCamera.ResetWorldToCameraMatrix(); ourCamera.ResetProjectionMatrix(); ourCamera = null; @@ -565,7 +565,6 @@ namespace UnityExplorer.UI.Panels UIFactory.SetLayoutElement(TargetCamLabel.gameObject, minWidth: 75, minHeight: 25); GameObject targetCameraDropdownObj = UIFactory.CreateDropdown(CameraModeRow, "TargetCamera_Dropdown", out targetCameraDropdown, null, 14, null); - targetCameraDropdown.onValueChanged.AddListener(UpdateTargetCameraAction); try {