Пример #1
0
        private static void LinkPackageToMod(UnityEditor.PackageManager.PackageInfo package)
        {
            var path = package.resolvedPath;
            var mod  = System.IO.Path.GetFileName(path);

            if (mod.Contains("@"))
            {
                mod = mod.Substring(0, mod.IndexOf('@'));
            }
            if (System.IO.Directory.Exists(path + "/Link~/Mod"))
            {
                var link = "Assets/Mods/" + mod;
                if (!System.IO.Directory.Exists(link) && !System.IO.File.Exists(link))
                {
                    System.IO.Directory.CreateDirectory("Assets/Mods/");
                    ResManagerEditorEntryUtils.MakeDirLink(link, path + "/Link~/Mod");
                    ResManagerEditorEntryUtils.AddGitIgnore("Assets/Mods/.gitignore", mod);
                }
            }
            for (int i = 0; i < UniqueSpecialFolders.Length; ++i)
            {
                var usdir  = UniqueSpecialFolders[i];
                var link   = "Assets/" + usdir + "/Mods/" + mod + "/Content";
                var target = path + "/Link~/" + usdir;
                if (System.IO.Directory.Exists(target) && !System.IO.Directory.Exists(link) && !System.IO.File.Exists(link))
                {
                    System.IO.Directory.CreateDirectory("Assets/" + usdir + "/Mods/" + mod);
                    ResManagerEditorEntryUtils.MakeDirLink(link, target);
                }
            }
        }
Пример #2
0
 private static void UnlinkMod(string mod)
 {
     UnlinkOrDeleteDir("Assets/Mods/" + mod);
     ResManagerEditorEntryUtils.RemoveGitIgnore("Assets/Mods/.gitignore", mod + "/");
     for (int i = 0; i < UniqueSpecialFolders.Length; ++i)
     {
         var usdir = UniqueSpecialFolders[i];
         var udir  = "Assets/" + usdir + "/Mods/" + mod;
         UnlinkOrDeleteDir(udir + "/Content");
         if (System.IO.Directory.Exists(udir))
         {
             System.IO.Directory.Delete(udir, true);
         }
     }
 }
Пример #3
0
 private static void UnlinkOrDeleteDir(string path)
 {
     if (ResManagerEditorEntryUtils.IsDirLink(path))
     {
         ResManagerEditorEntryUtils.DeleteDirLink(path);
     }
     else
     {
         if (System.IO.File.Exists(path))
         {
             System.IO.File.Delete(path);
         }
         else if (System.IO.Directory.Exists(path))
         {
             System.IO.Directory.Delete(path, true);
         }
     }
 }