Fixed Unity 6000.4 methods that have been marked as obsolete

This commit is contained in:
Anders Ejlersen 2026-03-31 21:43:28 +02:00
parent 230a976a52
commit fc7cdb2153
3 changed files with 26 additions and 2 deletions

View file

@ -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<Canvas>()
: Object.FindObjectsByType<Canvas>(FindObjectsInactive.Include);
System.Array.Sort(canvases, (c0, c1) => c0.GetEntityId().CompareTo(c1.GetEntityId()));
#else
var canvases = prefabStage != null
? prefabStage.prefabContentsRoot.GetComponentsInParent<Canvas>()
: Object.FindObjectsByType<Canvas>(FindObjectsInactive.Include, FindObjectsSortMode.InstanceID);
#endif
var list = new List<Canvas>(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;