Esempio n. 1
0
        public static void SaveFolderTree(string path, FolderTree folderTree, bool createWorkingCopy)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new UnityException("Cannot save Folder Tree: No spath specified to save the Folder Tree" +
                                         (folderTree != null ? folderTree.name : "") + " to!");
            }
            if (folderTree == null)
            {
                throw new UnityException(
                          "Cannot save NodeCanvas: The specified NodeCanvas that should be saved to path " + path +
                          " is null!");
            }
            if (!createWorkingCopy && AssetDatabase.Contains(folderTree) &&
                AssetDatabase.GetAssetPath(folderTree) != path)
            {
                Debug.LogError("Trying to create a duplicate save file for '" + folderTree.name + "'!");
                return;
            }

            ProcessFolderTree(ref folderTree, createWorkingCopy);
            AssetDatabase.CreateAsset(folderTree, path);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
        }
 private void LoadCache()
 {
     if (!FileUtility.Exists(LastSessionPath) || (FolderTree =
                                                      FolderManagerSaveManager.LoadFolderTree(LastSessionPath, false)) == null)
     {
         NewFolderTree();
         return;
     }
     FolderManager.RepaintClients();
 }
        private void NewFolderTree()
        {
            FolderTree              = ScriptableObject.CreateInstance <FolderTree>();
            FolderTree.name         = "New " + FolderTree.TreeName;
            FolderTree.TreeElements = new List <FolderTreeElement> {
                new FolderTreeElement("root", -1, -1)
                //  new FolderTreeElement("Root", 0, 0)
            };
            OpenedCanvasPath = "";

            SaveCache();
        }
        public void LoadFolderTree(string path)
        {
            if (!FileUtility.Exists(path) || (FolderTree = FolderManagerSaveManager.LoadFolderTree(path, true)) ==
                null)
            {
                NewFolderTree();
                return;
            }
            OpenedCanvasPath = path;

            SaveCache();
            FolderManager.RepaintClients();
        }
Esempio n. 5
0
        public static bool Generate(FolderTree folderTree)
        {
            if (folderTree.TreeElements.Count < 2)
            {
                return(false);
            }

            foreach (var element in folderTree.TreeElements)
            {
                DirectoryUtility.CheckAndCreateRelative(element.GetPath());
            }
            AssetDatabase.Refresh();
            return(true);
        }
Esempio n. 6
0
 private static FolderTree CreateWorkingCopy(FolderTree folderTree)
 {
     folderTree = Clone(folderTree);
     return(folderTree);
 }
Esempio n. 7
0
 private static void ProcessFolderTree(ref FolderTree folderTree, bool createWorkingCopy)
 {
     folderTree = CreateWorkingCopy(folderTree);
 }