public static void ClearAssetBundle() { string outputPath = Path.Combine(Path.Combine(System.Environment.CurrentDirectory, IPathTools.kAssetBundlesOutputPath), GetPlatformFolderForAssetBundles(EditorUserBuildSettings.activeBuildTarget)); outputPath = IPathTools.FixedPath(outputPath); Debug.Log(outputPath); if (Directory.Exists(outputPath)) { FileUtil.DeleteFileOrDirectory(outputPath); // Directory.Delete(outputPath, true); } outputPath = Path.Combine(Application.streamingAssetsPath, IPathTools.kAssetBundlesOutputPath); outputPath = Path.Combine(outputPath, GetPlatformFolderForAssetBundles(EditorUserBuildSettings.activeBuildTarget)); outputPath = IPathTools.FixedPath(outputPath); Debug.Log(outputPath); if (Directory.Exists(outputPath)) { FileUtil.DeleteFileOrDirectory(outputPath); // ITools.DeleteFolder(outputPath); } AssetDatabase.Refresh(); }
static void CopyAssetBundlesTo(string outputPath) { FileUtil.DeleteFileOrDirectory(Application.streamingAssetsPath); outputPath = IPathTools.FixedPath(outputPath); Directory.CreateDirectory(outputPath); string outputFolder = GetPlatformFolderForAssetBundles(EditorUserBuildSettings.activeBuildTarget); // Setup the source folder for assetbundles. var source = Path.Combine(Path.Combine(System.Environment.CurrentDirectory, IPathTools.kAssetBundlesOutputPath), outputFolder); if (!System.IO.Directory.Exists(source)) { Debug.Log("No assetBundle output folder, try to build the assetBundles first."); } // Setup the destination folder for assetbundles. var destination = System.IO.Path.Combine(outputPath, outputFolder); destination = IPathTools.FixedPath(destination); if (System.IO.Directory.Exists(destination)) { // Directory.CreateDirectory(destination); FileUtil.DeleteFileOrDirectory(destination); } Directory.Move(source, destination); // FileUtil.CopyFileOrDirectory(source, destination); // // Clear streaming assets folder. //FileUtil.DeleteFileOrDirectory(Application.streamingAssetsPath); // outputPath = ITools.FixedPath(outputPath); // Directory.CreateDirectory(outputPath); // string outputFolder = GetPlatformFolderForAssetBundles(EditorUserBuildSettings.activeBuildTarget); // // Setup the source folder for assetbundles. // var source = Path.Combine(Path.Combine(System.Environment.CurrentDirectory, ITools.kAssetBundlesOutputPath), outputFolder); // if (!System.IO.Directory.Exists(source)) // Debug.Log("No assetBundle output folder, try to build the assetBundles first."); // // Setup the destination folder for assetbundles. // var destination = System.IO.Path.Combine(outputPath, outputFolder); // if (System.IO.Directory.Exists(destination)) // FileUtil.DeleteFileOrDirectory(destination); // FileUtil.CopyFileOrDirectory(source, destination); }
/// <summary> /// /// </summary> /// <param name="file"></param> /// <param name="headPath">Assets/Art/Scences/ScencesOne</param> /// <returns></returns> public static string GetBundlePath(FileInfo file, string headPath) { string tmpPath = file.FullName; tmpPath = IPathTools.FixedPath(tmpPath); // Debug.Log("tmpPath 111=="+ tmpPath); headPath = IPathTools.FixedPath(headPath); // Debug.Log("headPath 111==" + headPath); int assetCount = tmpPath.IndexOf(headPath); //找到的 assetCount += headPath.Length + 1; int nameCount = tmpPath.LastIndexOf(file.Name); int tmpLenght = nameCount - assetCount; int tmpCount = headPath.LastIndexOf("/"); string scencsHead = headPath.Substring(tmpCount + 1, headPath.Length - tmpCount - 1); //有路径的话 标记 全路径 if (tmpLenght > 0) { string subString = tmpPath.Substring(assetCount, tmpPath.Length - assetCount); string[] resulat = subString.Split("/".ToCharArray()); return(scencsHead + "/" + resulat[0]); } else { return(scencsHead); } }
public static void CopyRecorder() { //string highRecorder = Application.dataPath + "/Art/Scences/Highrecord.txt"; //highRecorder = ITools.FixedPath(highRecorder); //string middleRecorder = Application.dataPath + "/Art/Scences/Middlerecord.txt"; //middleRecorder = ITools.FixedPath(middleRecorder); //string lowRecorder = Application.dataPath + "/Art/Scences/Lowrecord.txt"; //lowRecorder = ITools.FixedPath(lowRecorder); string path = Application.dataPath + "/Art/Scences/"; DirectoryInfo dir = new DirectoryInfo(path); FileSystemInfo[] filesInfo = dir.GetFileSystemInfos(); string dirPath = Path.Combine(Application.streamingAssetsPath, IPathTools.kAssetBundlesOutputPath); dirPath = Path.Combine(dirPath, GetPlatformFolderForAssetBundles(EditorUserBuildSettings.activeBuildTarget)); dirPath = IPathTools.FixedPath(dirPath); if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath); } for (int i = 0; i < filesInfo.Length; i++) { FileSystemInfo tmpFile = filesInfo[i]; if (tmpFile is FileInfo) { if (tmpFile.Extension != ".meta") { string filePath = dirPath + "/" + tmpFile.Name; filePath = IPathTools.FixedPath(filePath); Debug.Log("copy file path==" + filePath); File.Copy(tmpFile.FullName, filePath, true); } } } AssetDatabase.Refresh(); //string dirPath = Application.streamingAssetsPath + "/" + ITools.kAssetBundlesOutputPath + "/" + ITools.GetPlatformFolderForAssetBundles(Application.platform) + "/" + "high/"; //dirPath = ITools.FixedPath(dirPath); //if (!Directory.Exists(dirPath)) // Directory.CreateDirectory(dirPath); //dirPath += "Highrecord.txt"; //File.Copy(highRecorder, dirPath, true); //dirPath = Application.streamingAssetsPath + "/" + ITools.kAssetBundlesOutputPath + "/" + ITools.GetPlatformFolderForAssetBundles(Application.platform) + "/" + "middle/"; //dirPath = ITools.FixedPath(dirPath); //if (!Directory.Exists(dirPath)) // Directory.CreateDirectory(dirPath); //dirPath += "Middlerecord.txt"; //File.Copy(middleRecorder, dirPath, true); //dirPath = Application.streamingAssetsPath + "/" + ITools.kAssetBundlesOutputPath + "/" + ITools.GetPlatformFolderForAssetBundles(Application.platform) + "/" + "low/"; //dirPath = ITools.FixedPath(dirPath); //if (!Directory.Exists(dirPath)) // Directory.CreateDirectory(dirPath); //dirPath += "Lowrecord.txt"; //File.Copy(lowRecorder, dirPath, true); }