Пример #1
0
 private void DoEmptyFolderCheck(TreeNode node, List <string> dirs, List <string> all)
 {
     if (node.isDirectory)
     {
         //UnityEditor
         var found = AssetDatabase.FindAssets("", new[] { node.path }).ToList();
         PuSelection.ClearWarnings();
         if (!found.Except(dirs).Any() && all.Exists(a => a.Equals(node.path, StringComparison.OrdinalIgnoreCase)))
         {
             node.isChecked        = true;
             node.lastCheckedState = true;
         }
         foreach (var child in node.children)
         {
             DoEmptyFolderCheck(child, dirs, all);
         }
     }
 }
Пример #2
0
        public void PrepareForUnimport(string file2Import, string tempPath)
        {
            // test absolute
            if (!File.Exists(file2Import))
            {
                // test relative
                file2Import = Path.Combine(Environment.CurrentDirectory, file2Import);
                if (!File.Exists(file2Import))
                {
                    throw new FileNotFoundException(file2Import);
                }
            }

            if (!file2Import.ToLower().EndsWith(".unitypackage"))
            {
                throw new Exception("You must select *.unitypackage files.");
            }

            if (!Directory.Exists(tempPath))
            {
                Directory.CreateDirectory(tempPath);
            }

            EditorUtility.DisplayProgressBar("Uninstalling Package", "Initializing...", .25f);
            HolyGZip(file2Import, tempPath);

            EditorUtility.DisplayProgressBar("Uninstalling Package", "Fetching Package Structure...", .5f);
            List <AssetPath> fileList = GenerateAssetList(tempPath);


            var assetList = AssetDatabase.GetAllAssetPaths().ToList();
            var foundList = new List <string>();

            foreach (var item in assetList)
            {
                if (fileList.Exists((f) => f.filePath.Equals(item, StringComparison.OrdinalIgnoreCase)))
                {
                    foundList.Add(item);
                }
            }
            var dirs = PuSelection.DirectoriesPathList(fileList);

            EditorUtility.ClearProgressBar();
            bool goOn = true;

            if (foundList.Count <= 0)
            {
                if (!EditorUtility.DisplayDialog("No files found.", "It seems that '" + Path.GetFileNameWithoutExtension(file2Import) + "' doesn't exist in your project. Do you want to continue anyway?", "Continue Anyway", "No"))
                {
                    goOn = false;
                    PuSelection.RemoveMess(tempPath);
                }
            }
            if (goOn)
            {
                PuSelection pus = ScriptableObject.CreateInstance <PuSelection>();
                pus.fileList     = fileList;
                pus.directories  = dirs;
                pus.foundList    = foundList;
                pus.packageName  = Path.GetFileNameWithoutExtension(file2Import);
                pus.packagePath  = file2Import;
                pus.tempPath     = tempPath;
                pus.titleContent = new GUIContent("");
                pus.minSize      = new Vector2(300, 200);

                pus.ShowUtility();
            }
        }