From 9b6927610fedb70bc779eced701484a35fa35302 Mon Sep 17 00:00:00 2001 From: SlideDrum Date: Mon, 16 Mar 2026 06:54:32 -0400 Subject: [PATCH 1/2] Removed all instances of scene.handle since it no longer exists in unity 6. Replaced most of them with scene.name --- src/ObjectExplorer/SceneExplorer.cs | 2 +- src/ObjectExplorer/SceneHandler.cs | 23 ++++++++++++++----- src/ObjectExplorer/SearchProvider.cs | 2 +- src/UI/UIManager.cs | 7 +----- .../GameObjects/GameObjectInfoPanel.cs | 18 +++++++++++---- 5 files changed, 34 insertions(+), 18 deletions(-) diff --git a/src/ObjectExplorer/SceneExplorer.cs b/src/ObjectExplorer/SceneExplorer.cs index 18573fbe..9211a3f3 100644 --- a/src/ObjectExplorer/SceneExplorer.cs +++ b/src/ObjectExplorer/SceneExplorer.cs @@ -70,7 +70,7 @@ public void JumpToTransform(Transform transform) if (SceneHandler.SelectedScene != go.scene) { int idx; - if (go.scene == default || go.scene.handle == -1) + if (go.scene == default || go.scene.name == "DontDestroyOnLoad") //scene.handle no longer exists in Unity 6 idx = sceneDropdown.options.Count - 1; else idx = sceneDropdown.options.IndexOf(sceneToDropdownOption[go.scene]); diff --git a/src/ObjectExplorer/SceneHandler.cs b/src/ObjectExplorer/SceneHandler.cs index ab31be1d..a87187a4 100644 --- a/src/ObjectExplorer/SceneHandler.cs +++ b/src/ObjectExplorer/SceneHandler.cs @@ -46,10 +46,21 @@ internal set /// Whether or not the "DontDestroyOnLoad" scene exists in this game. public static bool DontDestroyExists { get; private set; } + private static bool DoesDontDestroyOnLoadExist() + { + for (int i = 0; i < SceneManager.sceneCount; i++) + { + Scene scene = SceneManager.GetSceneAt(i); + if (scene.name == "DontDestroyOnLoad") + return true; + } + return false; + } + internal static void Init() { // Check if the game has "DontDestroyOnLoad" - DontDestroyExists = Scene.GetNameInternal(-12) == "DontDestroyOnLoad"; + DontDestroyExists = DoesDontDestroyOnLoadExist(); // Try to get all scenes in the build settings. This may not work. try @@ -80,8 +91,8 @@ internal static void Update() // Inspected scene will exist if it's DontDestroyOnLoad or HideAndDontSave bool inspectedExists = SelectedScene.HasValue - && ((DontDestroyExists && SelectedScene.Value.handle == -12) - || SelectedScene.Value.handle == -1); + && ((DontDestroyExists && SelectedScene.Value.name == "DontDestroyOnLoad") + || !SelectedScene.Value.IsValid()); LoadedScenes.Clear(); @@ -98,9 +109,9 @@ internal static void Update() LoadedScenes.Add(scene); } - if (DontDestroyExists) - LoadedScenes.Add(new Scene { m_Handle = -12 }); - LoadedScenes.Add(new Scene { m_Handle = -1 }); + //if (DontDestroyExists) + // LoadedScenes.Add(new Scene { m_Handle = -12 }); + //LoadedScenes.Add(new Scene { m_Handle = -1 }); // Default to first scene if none selected or previous selection no longer exists. if (!inspectedExists) diff --git a/src/ObjectExplorer/SearchProvider.cs b/src/ObjectExplorer/SearchProvider.cs index 61e2f7eb..66804d50 100644 --- a/src/ObjectExplorer/SearchProvider.cs +++ b/src/ObjectExplorer/SearchProvider.cs @@ -31,7 +31,7 @@ private static bool Filter(Scene scene, SceneFilter filter) return filter switch { SceneFilter.Any => true, - SceneFilter.DontDestroyOnLoad => scene.handle == -12, + SceneFilter.DontDestroyOnLoad => scene.name == "DontDestroyOnLoad", //Scene.handle no longer exists in Unity 6 SceneFilter.HideAndDontSave => scene == default, SceneFilter.ActivelyLoaded => scene.buildIndex != -1, _ => false, diff --git a/src/UI/UIManager.cs b/src/UI/UIManager.cs index cc0ddf6f..f3715a66 100644 --- a/src/UI/UIManager.cs +++ b/src/UI/UIManager.cs @@ -128,21 +128,16 @@ public static void Update() { if (!UIRoot) return; - // If we are doing a Mouse Inspect, we don't need to update anything else. - if (MouseInspector.Instance.TryUpdate()) + if (MouseInspector.Instance?.TryUpdate() ?? false) //instance is sometimes null for some reason? return; - // Update Notification modal Notification.Update(); - // Check forceUnlockMouse toggle if (IInputManager.GetKeyDown(ConfigManager.Force_Unlock_Toggle.Value)) UniverseLib.Config.ConfigManager.Force_Unlock_Mouse = !UniverseLib.Config.ConfigManager.Force_Unlock_Mouse; - // update the timescale value timeScaleWidget.Update(); - // check screen dimension change Display display = DisplayManager.ActiveDisplay; if (display.renderingWidth != lastScreenWidth || display.renderingHeight != lastScreenHeight) diff --git a/src/UI/Widgets/GameObjects/GameObjectInfoPanel.cs b/src/UI/Widgets/GameObjects/GameObjectInfoPanel.cs index 19a80b87..6dbefe1a 100644 --- a/src/UI/Widgets/GameObjects/GameObjectInfoPanel.cs +++ b/src/UI/Widgets/GameObjects/GameObjectInfoPanel.cs @@ -1,4 +1,5 @@ -using UnityExplorer.UI.Panels; +using UnityEngine.SceneManagement; +using UnityExplorer.UI.Panels; using UniverseLib.UI; using UniverseLib.UI.Models; @@ -12,7 +13,7 @@ public class GameObjectInfoPanel string lastGoName; string lastPath; bool lastParentState; - int lastSceneHandle; + string lastSceneId; string lastTag; int lastLayer; int lastFlags; @@ -40,7 +41,16 @@ public GameObjectInfoPanel(GameObjectControls owner) this.Owner = owner; Create(); } + private static string GetSceneId(Scene scene) + { + if (!scene.IsValid()) + return "invalid"; + + if (!string.IsNullOrEmpty(scene.path)) + return scene.path; + return scene.name; + } public void UpdateGameObjectInfo(bool firstUpdate, bool force) { if (firstUpdate) @@ -92,9 +102,9 @@ public void UpdateGameObjectInfo(bool firstUpdate, bool force) IsStaticToggle.Set(Target.isStatic, false); } - if (force || Target.scene.handle != lastSceneHandle) + if (force || GetSceneId(Target.scene) != lastSceneId) //scene.handle no longer exists in unity 6, had to replace it with something else. { - lastSceneHandle = Target.scene.handle; + lastSceneId = GetSceneId(Target.scene); SceneButton.ButtonText.text = Target.scene.IsValid() ? Target.scene.name : "None (Asset/Resource)"; } From 3f4f5e228d06b5e6ee8e79c29710f65ed92577a4 Mon Sep 17 00:00:00 2001 From: SlideDrum Date: Mon, 16 Mar 2026 07:00:32 -0400 Subject: [PATCH 2/2] Removed MouseInspector.Instance null check. --- src/UI/UIManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/UI/UIManager.cs b/src/UI/UIManager.cs index f3715a66..3bebf454 100644 --- a/src/UI/UIManager.cs +++ b/src/UI/UIManager.cs @@ -129,7 +129,7 @@ public static void Update() if (!UIRoot) return; // If we are doing a Mouse Inspect, we don't need to update anything else. - if (MouseInspector.Instance?.TryUpdate() ?? false) //instance is sometimes null for some reason? + if (MouseInspector.Instance.TryUpdate()) return; // Update Notification modal Notification.Update();