protected override void DoubleClickedItem(int id) { if (!findResultItems.ContainsKey(id)) { SetExpanded(id, true); return; } var request = findResultItems[id].UsageElement; switch (request) { case SceneElement sceneElement: ShowUtil.ShowUsageOnScene(sceneElement.FilePath, sceneElement.FileName, sceneElement.Path, sceneElement.RootIndices); break; case PrefabElement _: case ScriptableObjectElement _: ShowUtil.ShowFileUsage(request.FilePath); break; case AnimatorElement animatorElement: var elements = animatorElement.PathElements; var range = elements.ToList().GetRange(0, myAnimatorItemIdToPathElementsCount[id]); ShowUtil.ShowAnimatorUsage(range.ToArray(), animatorElement.FilePath); break; case AnimationElement animationElement: ShowUtil.ShowAnimationEventUsage(animationElement.FilePath); break; } }
public static void OnModelInitializationHandler(UnityModelAndLifetime modelAndLifetime) { var modelValue = modelAndLifetime.Model; var connectionLifetime = modelAndLifetime.Lifetime; modelValue.ShowUsagesInUnity.Advise(connectionLifetime, findUsagesResult => { if (findUsagesResult != null) { MainThreadDispatcher.Instance.Queue(() => { ExpandMinimizedUnityWindow(); EditorUtility.FocusProjectWindow(); switch (findUsagesResult) { case AnimatorFindUsagesResult animatorUsage: ShowUtil.ShowAnimatorUsage(animatorUsage.PathElements, animatorUsage.FilePath); return; case HierarchyFindUsagesResult _ when findUsagesResult.Extension.Equals(".prefab", StringComparison.OrdinalIgnoreCase): ShowUtil.ShowFileUsage(findUsagesResult.FilePath); break; case HierarchyFindUsagesResult hierarchyFindUsagesResult: ShowUtil.ShowUsageOnScene(findUsagesResult.FilePath, findUsagesResult.FileName, hierarchyFindUsagesResult.PathElements, hierarchyFindUsagesResult.RootIndices); break; case AnimationFindUsagesResult animationEventUsage: ShowUtil.ShowAnimationEventUsage(animationEventUsage.FilePath); break; default: ShowUtil.ShowFileUsage(findUsagesResult.FilePath); break; } }); } }); modelValue.SendFindUsagesSessionResult.Advise(connectionLifetime, result => { if (result != null) { MainThreadDispatcher.Instance.Queue(() => { GUI.BringWindowToFront(EditorWindow.GetWindow <SceneView>().GetInstanceID()); GUI.BringWindowToFront(EditorWindow.GetWindow(typeof(SceneView).Assembly.GetType("UnityEditor.SceneHierarchyWindow")).GetInstanceID()); GUI.BringWindowToFront(EditorWindow.GetWindow(typeof(SceneView).Assembly.GetType("UnityEditor.ProjectBrowser")).GetInstanceID()); var window = FindUsagesWindow.GetWindow(result.Target); window.SetDataToEditor(result.Elements); }); } }); modelValue.ShowFileInUnity.Advise(connectionLifetime, result => { if (result != null) { MainThreadDispatcher.Instance.Queue(() => { ExpandMinimizedUnityWindow(); EditorUtility.FocusProjectWindow(); ShowUtil.ShowFileUsage(result); }); } }); }