예제 #1
0
        protected override void DoubleClickedItem(int id)
        {
            if (!findResultItems.ContainsKey(id))
            {
                SetExpanded(id, true);
                return;
            }

            var request = findResultItems[id].UsageElement;

            if (request is SceneElement sceneElement)
            {
                ShowUtil.ShowUsageOnScene(sceneElement.FilePath, sceneElement.FileName, sceneElement.Path, sceneElement.RootIndices);
            }

            if (request is PrefabElement prefabElement)
            {
                ShowUtil.ShowPrefabUsage(prefabElement.FilePath, prefabElement.Path);
            }
        }
예제 #2
0
        public static void OnModelInitializationHandler(UnityModelAndLifetime modelAndLifetime)
        {
            var modelValue         = modelAndLifetime.Model;
            var connectionLifetime = modelAndLifetime.Lifetime;

            modelValue.ShowGameObjectOnScene.Advise(connectionLifetime, findUsagesResult =>
            {
                if (findUsagesResult != null)
                {
                    MainThreadDispatcher.Instance.Queue(() =>
                    {
                        if (findUsagesResult.IsPrefab)
                        {
                            ShowUtil.ShowPrefabUsage(findUsagesResult.FilePath, findUsagesResult.PathElements);
                        }
                        else
                        {
                            ShowUtil.ShowUsageOnScene(findUsagesResult.FilePath, findUsagesResult.FileName, findUsagesResult.PathElements, findUsagesResult.RootIndices);
                        }
                    });
                }
            });

            modelValue.FindUsageResults.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);
                    });
                }
            });
        }