Esempio n. 1
0
 /// <summary>
 /// 打包
 /// </summary>
 /// <param name="path">资源地址</param>
 /// <param name="originManifestName">原始总配置文件名称</param>
 /// <param name="curManifestName">要使用的总配置文件名称</param>
 private static void Build(string path, string originManifestName, string curManifestName)
 {
     MarkAssetBundleFiles();
     if (FileUtilities.CheckDirectory(path, true))
     {
         BuildPipeline.BuildAssetBundles(
             path,
             BuildAssetBundleOptions.ChunkBasedCompression |
             BuildAssetBundleOptions.DeterministicAssetBundle,
             CurBuildTarget);
         string originManifestPath = string.Format("{0}/{1}", path, originManifestName);
         string manifestPath       = string.Format("{0}/{1}", path, curManifestName);
         if (File.Exists(originManifestPath))
         {
             if (File.Exists(manifestPath))
             {
                 File.Delete(manifestPath);
                 File.Delete(string.Format("{0}.manifest", manifestPath));
             }
             File.Move(originManifestPath, manifestPath);
             File.Move(string.Format("{0}.manifest", originManifestPath), string.Format("{0}.manifest", manifestPath));
         }
     }
     AssetDatabase.Refresh();
 }
        public void CheckDirectory_ShouldSetErrorToTrue_ForNonexistentDirectory()
        {
            const string directory = "C:\\test\\non_existent_path\\directory";
            bool         result    = false;

            FileUtilities.CheckDirectory(directory, SearchDirectoryType.Primary, ref result);

            Assert.True(result);
        }
        public void CheckDirectory_ShouldNotSetError_ForExistingDirectory()
        {
            bool result1 = false;
            bool result2 = true;

            FileUtilities.CheckDirectory(testDirectory, SearchDirectoryType.Primary, ref result1);
            FileUtilities.CheckDirectory(testDirectory, SearchDirectoryType.Primary, ref result2);

            Assert.False(result1);
            Assert.True(result2);
        }
Esempio n. 4
0
    /// <summary>
    /// 获得要标记的文件
    /// </summary>
    /// <returns></returns>
    private static List <string> GetWannaMarkFiles()
    {
        string _rootPath = string.Format("{0}/{1}", Application.dataPath, Config.Get <string> ("AssetFolder"));

        if (FileUtilities.CheckDirectory(_rootPath))
        {
            string[]      filePaths = Directory.GetFiles(_rootPath, "*.*", SearchOption.AllDirectories);
            List <string> allFiles  = new List <string> ();
            for (int i = 0; i < filePaths.Length; i++)
            {
                if (JudgeExtension(filePaths[i]))
                {
                    string _filePath = filePaths[i].Substring(filePaths[i].IndexOf("Assets"));
                    allFiles.Add(_filePath);
                    Debug.LogFormat(DebugFormat, "MarkFiles", _filePath);
                }
            }
            return(allFiles);
        }
        else
        {
            throw new Exception(string.Format("资源文件夹不存在:{0}", _rootPath));
        }
    }