public FolderNode GetOrCreate(string name, string fullPath)
        {
            var parent = Folders.FirstOrDefault(i => i.Name == name);

            if (parent == null)
            {
                parent = new FolderNode(name, fullPath);
                Add(parent);
            }

            return(parent);
        }
Esempio n. 2
0
        private FolderNode RegenerateRootNode()
        {
            var rootNode = new FolderNode("root", "");
            var assets   = AssetDatabase.FindAssets("*", new[] { EditorNode.RootPath });

            foreach (var asset in assets)
            {
                var path = AssetDatabase.GUIDToAssetPath(asset);

                Add(rootNode, path);
            }

            return(rootNode);
        }
Esempio n. 3
0
        public void RefreshCache()
        {
            // Debug.Log("Asset Cache Refresh");

            _rootNode = RegenerateRootNode();

            var removedPaths = Options
                               .ExpandStates.Keys
                               .Except(FolderNode.GetNodes(_rootNode).Select(n => n.RelativePath))
                               .ToList();

            removedPaths.ForEach(it => Options.ExpandStates.Remove(it));
            Options.Save();
        }
        public static IEnumerable <INode> GetNodes(FolderNode root)
        {
            foreach (var child in root.Folders)
            {
                yield return(child);

                foreach (var other in GetNodes(child))
                {
                    yield return(other);
                }
            }

            foreach (var child in root.Editors)
            {
                yield return(child);
            }
        }
Esempio n. 5
0
        public void Add(FolderNode rootNode, string path)
        {
            var shortenedPath = path.Substring(EditorNode.RootPath.Length + 1);
            var prettyName    = Path.GetFileNameWithoutExtension(shortenedPath);
            var parts         = prettyName.Split('.');

            FolderNode currentNode = rootNode;

            _builder.Clear();

            for (var i = 0; i < parts.Length - 1; i++)
            {
                if (i > 0)
                {
                    _builder.Append(".");
                }

                _builder.Append(parts[i]);

                currentNode = currentNode.GetOrCreate(parts[i], _builder.ToString());
            }

            currentNode.Add(new EditorNode(parts[parts.Length - 1], shortenedPath));
        }
Esempio n. 6
0
 public void MarkOutOfDate()
 {
     _rootNode = null;
 }