From fc7cdb2153ee78a0e7e3a17a05ad5e57671fb8a0 Mon Sep 17 00:00:00 2001 From: Anders Ejlersen Date: Tue, 31 Mar 2026 21:43:28 +0200 Subject: [PATCH] Fixed Unity 6000.4 methods that have been marked as obsolete --- CHANGELOG.md | 6 ++++++ .../MainToolbarUIElement.cs | 20 ++++++++++++++++++- package.json | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1cb8e5..b5cd07f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # Change Log All notable changes to this project will be documented in this file. +## [2.0.3] - 2026-03-31 + +### Fixed +- Fixed Unity 6000.4 methods that have been marked as obsolete + + ## [2.0.2] - 2025-12-15 ### Fixed diff --git a/Editor/Toolbar/MainToolbarElements/MainToolbarUIElement.cs b/Editor/Toolbar/MainToolbarElements/MainToolbarUIElement.cs index dc44b86..b349d55 100644 --- a/Editor/Toolbar/MainToolbarElements/MainToolbarUIElement.cs +++ b/Editor/Toolbar/MainToolbarElements/MainToolbarUIElement.cs @@ -41,10 +41,19 @@ namespace Module.NavigationTool.Editor.Toolbar private static void OnDropdownOpen(Rect rect) { var prefabStage = PrefabStageUtility.GetCurrentPrefabStage(); + +#if UNITY_6000_4_OR_NEWER + var canvases = prefabStage != null + ? prefabStage.prefabContentsRoot.GetComponentsInParent() + : Object.FindObjectsByType(FindObjectsInactive.Include); + + System.Array.Sort(canvases, (c0, c1) => c0.GetEntityId().CompareTo(c1.GetEntityId())); +#else var canvases = prefabStage != null ? prefabStage.prefabContentsRoot.GetComponentsInParent() : Object.FindObjectsByType(FindObjectsInactive.Include, FindObjectsSortMode.InstanceID); - +#endif + var list = new List(canvases.Length); var menu = new GenericMenu(); @@ -56,13 +65,22 @@ namespace Module.NavigationTool.Editor.Toolbar continue; list.Add(root); + +#if UNITY_6000_4_OR_NEWER + menu.AddItem(new GUIContent($"{i}: {root.name}"), false, () => Focus(root.GetEntityId())); +#else menu.AddItem(new GUIContent($"{i}: {root.name}"), false, () => Focus(root.GetInstanceID())); +#endif } menu.DropDown(rect); } +#if UNITY_6000_4_OR_NEWER + private static void Focus(EntityId instanceId) +#else private static void Focus(int instanceId) +#endif { var obj = EditorUtility.EntityIdToObject(instanceId); var canvas = obj as Canvas; diff --git a/package.json b/package.json index 62aa855..6d61fd3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.module.navigationtool", - "version": "2.0.2", + "version": "2.0.3", "displayName": "Module.NavigationTool", "description": "Support for navigation tools, like favorites, history and toolbars", "unity": "2019.2",