Exemplo n.º 1
0
 public void Init(DependencyAbstractFinder d)
 {
     _data                = d;
     _labelMaxWidth       = CalculateContentMaxWidth(EditorStyles.label, _data.Dependencies.SelectMany(dd => dd.Properties.Select(p => p.Content)));
     _rowPropWidth        = CalculateContentMaxWidth(EditorStyles.label, _data.Target.Nested.Union(new[] { _data.Target.Root }).Where(o => o).Select(o => new GUIContent((o is ScriptableObject || o is MonoScript) ? o.ToString() : o.name)));
     titleContent         = new GUIContent($"{FindMode.GetWindowTitleByFindMode(_findMode)}");
     titleContent.tooltip = _data.Title;
 }
Exemplo n.º 2
0
        public void Init(DependencyAbstractFinder d)
        {
            _data = d;
            // _labelMaxWidth = CalculateContentMaxWidth(EditorStyles.label, _data.Dependencies.SelectMany(dd => dd.Properties.Select(p => p.Content)));

            // var t = new[] {_data.Target.Root};
            // if (_data.Target.Nested.TryGet(out var nested))

            titleContent         = new GUIContent($"{FindMode.GetWindowTitleByFindMode(_findMode)}");
            titleContent.tooltip = _data.Title;
        }
Exemplo n.º 3
0
        void ShowDependencies(ResultRow[] dependencies)
        {
            var nDeps = dependencies.Count();

            _expandFiles = EditorGUILayout.Foldout(_expandFiles, $"{FindMode.GetContentByFindMode(_findMode)}: [{nDeps}]");

            if (_findMode == FindModeEnum.File)
            {
                if (_data.Target.Scene.IsValid() && !_data.Target.Scene.isLoaded)
                {
                    return;
                }
            }

            if (_expandFiles)
            {
                if (nDeps > 0)
                {
                    foreach (var dependency in dependencies)
                    {
                        if (dependency != null && dependency.SerializedObject != null && dependency.SerializedObject.targetObject != null)
                        {
                            DrawRow(dependency);
                        }
                        else
                        {
                            this.Close();
                        }
                    }
                }
                else
                {
                    EditorGUILayout.LabelField("No file dependencies found.");
                }
            }

            EditorGUILayout.Space();

            var fileDep = _data as FileDependencyFinder;

            if (fileDep == null)
            {
                return;
            }

            if (fileDep.ScenePaths == null)
            {
                fileDep.ScenePaths = DependencyFinderEngine.GetScenesThatContain(_data.Target.Target)
                                     .Select(p => new FileDependencyFinder.Pair {
                    Path = p, NicifiedPath = p.Replace("Assets/", string.Empty)
                }).ToArray();
            }

            var nScenes = fileDep.ScenePaths.Count();

            _expandScenes = EditorGUILayout.Foldout(_expandScenes, $"In Scenes: [{nScenes}]");

            if (!_expandScenes)
            {
                return;
            }
            if (nScenes > 0)
            {
                foreach (var p in fileDep.ScenePaths)
                {
                    using (new EditorGUILayout.HorizontalScope()) {
                        SceneIcon.text = p.NicifiedPath;

                        if (GUILayout.Button(SceneIcon, EditorStyles.label, GUILayout.Height(16f)))
                        {
                            Selection.activeObject = AssetDatabase.LoadAssetAtPath <SceneAsset>(p.Path);
                        }

                        if (!GUILayout.Button("Open scene & search", GUILayout.Width(200f)))
                        {
                            continue;
                        }

                        var sceneToOpen = SceneManager.GetSceneByPath(p.Path);
                        if (sceneToOpen.isLoaded)
                        {
                            GuiManager.OpenSceneWindow(_data.Target.Target, p.Path);
                        }
                        else
                        {
                            var currentScene = EditorSceneManager.GetActiveScene();

                            if (currentScene.isDirty && EditorUtility.DisplayDialog(
                                    $"Unsaved changes",
                                    $"You are going to open and search in scene [{p.Path}]\n" +
                                    $"but you have unsaved shanges at the scene [{currentScene.name}]",
                                    $"Stay at current scene and cancel search", $"Discard changes and search"))
                            {
                                return;
                            }

                            EditorSceneManager.OpenScene(p.Path);
                            GuiManager.OpenSceneWindow(_data.Target.Target, p.Path);
                        }
                    }
                }
            }
            else
            {
                EditorGUILayout.LabelField("No scene dependencies found.");
            }
        }