static public void CopyAssetBundlesTo(string outputPath) { // Clear streaming assets folder. // FileUtil.DeleteFileOrDirectory(Application.streamingAssetsPath); if (!Directory.Exists(outputPath)) { Directory.CreateDirectory(outputPath); } string outputFolder = EditorUtility.GetPlatformName(); // Setup the source folder for assetbundles. var source = Path.Combine(Path.Combine(System.Environment.CurrentDirectory, EditorUtility.AssetBundlesOutputPath), 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); }
static void BuildAtlas() { foreach (var item in builds) { var assets = item.assetNames; foreach (var asset in assets) { var importer = AssetImporter.GetAtPath(asset); if (importer is TextureImporter) { var ti = importer as TextureImporter; if (ti.textureType == TextureImporterType.Sprite) { var tex = AssetDatabase.LoadAssetAtPath <Texture>(asset); if (tex.texelSize.x >= 1024 || tex.texelSize.y >= 1024) { continue; } var tag = item.assetBundleName.Replace("/", "_"); if (!tag.Equals(ti.spritePackingTag)) { var settings = ti.GetPlatformTextureSettings(EditorUtility.GetPlatformName()); settings.format = ti.GetAutomaticFormat(EditorUtility.GetPlatformName()); settings.overridden = true; ti.SetPlatformTextureSettings(settings); ti.spritePackingTag = tag; ti.SaveAndReimport(); } } } } } }
static public string CreateAssetBundleDirectory() { // Choose the output path according to the build target. string outputPath = Path.Combine(EditorUtility.AssetBundlesOutputPath, EditorUtility.GetPlatformName()); if (!Directory.Exists(outputPath)) Directory.CreateDirectory(outputPath); return outputPath; }
static string GetAssetBundleManifestFilePath() { var relativeAssetBundlesOutputPathForPlatform = Path.Combine(EditorUtility.AssetBundlesOutputPath, EditorUtility.GetPlatformName()); return(Path.Combine(relativeAssetBundlesOutputPathForPlatform, EditorUtility.GetPlatformName()) + ".manifest"); }
//获取打包路径 static public string CreateAssetBundleDirectory() { // Choose the output path according to the build target. // string outputPath = Path.Combine(EditorUtility.AssetBundlesOutputPath, EditorUtility.GetPlatformName()); // string outputPath = string.Format("{0}/{1}/{2}",Application.dataPath, EditorUtility.AssetBundlesOutputPath, EditorUtility.GetPlatformName());// Path.Combine(EditorUtility.AssetBundlesOutputPath, EditorUtility.GetPlatformName()); string outputPath = string.Format("{0}/{1}/{2}", Application.streamingAssetsPath, EditorUtility.AssetBundlesOutputPath, EditorUtility.GetPlatformName()); if (!Directory.Exists(outputPath)) { Directory.CreateDirectory(outputPath); } else { Directory.Delete(outputPath, true); Directory.CreateDirectory(outputPath); } return(outputPath); }