diff --git a/package-examples/Editor/API/SearchWalker.cs b/package-examples/Editor/API/SearchWalker.cs index 19cd6be..27d19e0 100644 --- a/package-examples/Editor/API/SearchWalker.cs +++ b/package-examples/Editor/API/SearchWalker.cs @@ -112,7 +112,11 @@ static IEnumerable EnumerateObjects(ICollection ids) var containerPath = AssetDatabase.GUIDToAssetPath(gid.assetGUID); var mainInstanceID = GetMainAssetInstanceID(containerPath); +#if UNITY_6000_5_OR_NEWER + AssetDatabase.OpenAsset((EntityId)mainInstanceID); +#else AssetDatabase.OpenAsset(mainInstanceID); +#endif yield return null; var scene = UnityEngine.SceneManagement.SceneManager.GetActiveScene(); diff --git a/package-examples/Editor/Providers/EasySearchProviderExample.cs b/package-examples/Editor/Providers/EasySearchProviderExample.cs index d3d903e..83fa6bb 100644 --- a/package-examples/Editor/Providers/EasySearchProviderExample.cs +++ b/package-examples/Editor/Providers/EasySearchProviderExample.cs @@ -108,7 +108,11 @@ public static SearchProvider ExampleEditorBundles() { Func FR = r => string.Equals(AssetDatabase.GetAssetPath(r), "Library/unity editor resources", StringComparison.Ordinal); return EasySearchProvider.Create(ExampleProvider.res.ToString(), "Resources", Resources.FindObjectsOfTypeAll().Where(FR)) +#if UNITY_6000_5_OR_NEWER + .SetDescriptionHandler(r => $"{r.GetType().FullName} ({(int)EntityId.ToULong(r.GetEntityId())})") +#else .SetDescriptionHandler(r => $"{r.GetType().FullName} ({r.GetInstanceID()})") +#endif .AddAction("select", o => Selection.activeObject = o) .AddAction("copy", "Copy Name", r => EditorGUIUtility.systemCopyBuffer = r.name) .AddOption(ShowDetailsOptions.Actions | ShowDetailsOptions.Inspector) diff --git a/package/Collections/SearchCollectionTreeView.cs b/package/Collections/SearchCollectionTreeView.cs index 9700949..83acb0b 100644 --- a/package/Collections/SearchCollectionTreeView.cs +++ b/package/Collections/SearchCollectionTreeView.cs @@ -6,6 +6,12 @@ using UnityEngine; using System.Reflection; +#if UNITY_6000_5_OR_NEWER +using TreeView = UnityEditor.IMGUI.Controls.TreeView; +using TreeViewItem = UnityEditor.IMGUI.Controls.TreeViewItem; +using TreeViewState = UnityEditor.IMGUI.Controls.TreeViewState; +#endif + namespace UnityEditor.Search.Collections { class SearchCollectionTreeView : TreeView diff --git a/package/Collections/SearchCollectionTreeViewItem.cs b/package/Collections/SearchCollectionTreeViewItem.cs index 521c1e5..21676ac 100644 --- a/package/Collections/SearchCollectionTreeViewItem.cs +++ b/package/Collections/SearchCollectionTreeViewItem.cs @@ -5,8 +5,12 @@ using UnityEditor.IMGUI.Controls; using UnityEngine; +#if UNITY_6000_5_OR_NEWER +using TreeViewItem = UnityEditor.IMGUI.Controls.TreeViewItem; +#endif + namespace UnityEditor.Search.Collections -{ +{ class SearchCollectionTreeViewItem : SearchTreeViewItem { #if UNITY_2021_2_OR_NEWER diff --git a/package/Collections/SearchCollectionView.cs b/package/Collections/SearchCollectionView.cs index 6c222dc..b8559fb 100644 --- a/package/Collections/SearchCollectionView.cs +++ b/package/Collections/SearchCollectionView.cs @@ -5,6 +5,10 @@ using UnityEditor.IMGUI.Controls; using UnityEngine; +#if UNITY_6000_5_OR_NEWER +using TreeViewState = UnityEditor.IMGUI.Controls.TreeViewState; +#endif + namespace UnityEditor.Search.Collections { interface ISearchCollectionHostView diff --git a/package/Collections/SearchTreeViewItem.cs b/package/Collections/SearchTreeViewItem.cs index 7aa65ac..de9ebdd 100644 --- a/package/Collections/SearchTreeViewItem.cs +++ b/package/Collections/SearchTreeViewItem.cs @@ -4,6 +4,10 @@ using UnityEditor.IMGUI.Controls; using UnityEngine; +#if UNITY_6000_5_OR_NEWER +using TreeViewItem = UnityEditor.IMGUI.Controls.TreeViewItem; +#endif + namespace UnityEditor.Search.Collections { class SearchTreeViewItem : TreeViewItem diff --git a/package/Dependencies/Dependency.cs b/package/Dependencies/Dependency.cs index ffea9cb..c52e1ee 100644 --- a/package/Dependencies/Dependency.cs +++ b/package/Dependencies/Dependency.cs @@ -284,7 +284,7 @@ public static int GetReferenceCount(string id) internal static IEnumerable EnumerateIdFromObjects(IEnumerable objects) { foreach (var obj in objects) - yield return GlobalObjectId.GetGlobalObjectIdSlow(obj.GetInstanceID()).ToString(); + yield return GlobalObjectId.GetGlobalObjectIdSlow(obj).ToString(); } internal static IEnumerable EnumeratePaths(IEnumerable globalIds) @@ -304,14 +304,22 @@ internal static IEnumerable EnumerateIdInfos(IEnumerable globalI var info = new IdInfo(); info.globalId = gid.ToString(); +#if UNITY_6000_5_OR_NEWER + info.instanceID = GlobalObjectId.GlobalObjectIdentifierToEntityIdSlow(gid); +#else info.instanceID = GlobalObjectId.GlobalObjectIdentifierToInstanceIDSlow(gid); +#endif info.path = AssetDatabase.GetAssetPath(info.instanceID); if (!string.IsNullOrEmpty(info.path)) { info.isAssetId = true; yield return info; } +#if UNITY_6000_5_OR_NEWER + else if (EditorUtility.EntityIdToObject(info.instanceID) is UnityEngine.Object obj) +#else else if (EditorUtility.InstanceIDToObject(info.instanceID) is UnityEngine.Object obj) +#endif { info.path = SearchUtils.GetObjectPath(obj).Substring(1); yield return info; diff --git a/package/Dependencies/DependencyBuiltinStates.cs b/package/Dependencies/DependencyBuiltinStates.cs index 0617854..07916f2 100644 --- a/package/Dependencies/DependencyBuiltinStates.cs +++ b/package/Dependencies/DependencyBuiltinStates.cs @@ -138,7 +138,12 @@ static DependencyViewerState StateFromObjects(string stateName, IEnumerable SceneUses(SearchExpressionContext c) static IEnumerable GetSceneObjectDependencies(SearchContext context, SearchProvider sceneProvider, SearchProvider depProvider, int instanceId) { +#if UNITY_6000_5_OR_NEWER + var obj = EditorUtility.EntityIdToObject(instanceId); +#else var obj = EditorUtility.InstanceIDToObject(instanceId); +#endif if (!obj) yield break; - var go = EditorUtility.InstanceIDToObject(instanceId) as GameObject; + var go = obj as GameObject; if (!go && obj is Component goc) { foreach (var ce in GetComponentDependencies(context, sceneProvider, depProvider, goc)) @@ -149,7 +153,11 @@ static void CreateItemsFromSelection(Action yielder) if (!string.IsNullOrEmpty(assetPath)) yielder(SearchExpression.CreateItem(assetPath)); else +#if UNITY_6000_5_OR_NEWER + yielder(SearchExpression.CreateItem((int)EntityId.ToULong(obj.GetEntityId()))); +#else yielder(SearchExpression.CreateItem(obj.GetInstanceID())); +#endif #else if (!string.IsNullOrEmpty(assetPath)) yielder(EvaluatorUtils.CreateItem(assetPath)); diff --git a/package/Dependencies/DependencyTableViewIMGUI.cs b/package/Dependencies/DependencyTableViewIMGUI.cs index 10cea37..d209570 100644 --- a/package/Dependencies/DependencyTableViewIMGUI.cs +++ b/package/Dependencies/DependencyTableViewIMGUI.cs @@ -1,4 +1,5 @@ -#if !UNITY_7000_0_OR_NEWER +// PropertyTable (IMGUI) was deprecated in 6000.5; this view is only used below 2023.1 (see DependencyViewer.CreateTableView). +#if !UNITY_6000_5_OR_NEWER #pragma warning disable CS0618 using System.Collections.Generic; using System; diff --git a/package/Dependencies/DependencyViewerState.cs b/package/Dependencies/DependencyViewerState.cs index a473dff..0e2b4c3 100644 --- a/package/Dependencies/DependencyViewerState.cs +++ b/package/Dependencies/DependencyViewerState.cs @@ -23,7 +23,11 @@ struct IdInfo { public string globalId; public string path; +#if UNITY_6000_5_OR_NEWER + public EntityId instanceID; +#else public int instanceID; +#endif public bool isAssetId; } @@ -178,12 +182,21 @@ IEnumerable EnumeratePaths() { if (!GlobalObjectId.TryParse(sgid, out var gid)) continue; +#if UNITY_6000_5_OR_NEWER + var instanceId = GlobalObjectId.GlobalObjectIdentifierToEntityIdSlow(gid); + var assetPath = AssetDatabase.GetAssetPath(instanceId); + if (!string.IsNullOrEmpty(assetPath)) + yield return assetPath; + else if (EditorUtility.EntityIdToObject(instanceId) is UnityEngine.Object obj) + yield return SearchUtils.GetObjectPath(obj).Substring(1); +#else var instanceId = GlobalObjectId.GlobalObjectIdentifierToInstanceIDSlow(gid); var assetPath = AssetDatabase.GetAssetPath(instanceId); if (!string.IsNullOrEmpty(assetPath)) yield return assetPath; else if (EditorUtility.InstanceIDToObject(instanceId) is UnityEngine.Object obj) yield return SearchUtils.GetObjectPath(obj).Substring(1); +#endif } } } diff --git a/package/Dependencies/Graph/DependencyGraphViewer.cs b/package/Dependencies/Graph/DependencyGraphViewer.cs index a8f8e49..38b7cc7 100644 --- a/package/Dependencies/Graph/DependencyGraphViewer.cs +++ b/package/Dependencies/Graph/DependencyGraphViewer.cs @@ -548,7 +548,7 @@ void DrawNodeWindow(in Rect windowRect, Event evt, in Node node) { selectedNode = node; if (selectedObject) - EditorGUIUtility.PingObject(selectedObject.GetInstanceID()); + EditorGUIUtility.PingObject(selectedObject); } else if (evt.clickCount == 2) { diff --git a/package/Dependencies/Graph/DependencyUtilities.cs b/package/Dependencies/Graph/DependencyUtilities.cs index da959c3..14b6701 100644 --- a/package/Dependencies/Graph/DependencyUtilities.cs +++ b/package/Dependencies/Graph/DependencyUtilities.cs @@ -123,6 +123,8 @@ public static int GetMainAssetInstanceID(string path) { #if !USE_SEARCH_EXTENSION_API return Utils.GetMainAssetInstanceID(path); +#elif UNITY_6000_5_OR_NEWER + return (int)EntityId.ToULong(SearchUtils.GetMainAssetEntityId(path)); #else return SearchUtils.GetMainAssetInstanceID(path); #endif diff --git a/package/Dependencies/SearchViewModelEx.cs b/package/Dependencies/SearchViewModelEx.cs index 50404a8..5fd30c7 100644 --- a/package/Dependencies/SearchViewModelEx.cs +++ b/package/Dependencies/SearchViewModelEx.cs @@ -98,6 +98,11 @@ public string currentGroup #else public int viewId { get; set; } #endif + +#if UNITY_6000_5_OR_NEWER + string m_CurrentResultViewId; + string ISearchView.currentResultViewId { get => m_CurrentResultViewId; set => m_CurrentResultViewId = value; } +#endif public Action addToItemContextualMenu; public Action executeAction; #endregion diff --git a/package/Overlays/SearchViewElement.cs b/package/Overlays/SearchViewElement.cs index aadb436..80740fa 100644 --- a/package/Overlays/SearchViewElement.cs +++ b/package/Overlays/SearchViewElement.cs @@ -230,6 +230,11 @@ IEnumerable ISearchView.GetAllVisibleErrors() throw new NotImplementedException(); } +#if UNITY_6000_5_OR_NEWER + string m_CurrentResultViewId; + string ISearchView.currentResultViewId { get => m_CurrentResultViewId; set => m_CurrentResultViewId = value; } +#endif + #if UNITY_6000_4_OR_NEWER EntityId ISearchView.GetViewId() {