//[MenuItem("Test/TestCopy")] //public static void CopyAndroidToPublish() //{ // CopyAndroidToPublish("BuYu_AnySDK"); //} public static void CopyAndroidToPublish(string androidName) { ClearPublishDir(); string from = AndroidRootDir + "/" + androidName; string to = PublishDir; if (!Directory.Exists(to)) { Directory.CreateDirectory(to); } List <string> files = new List <string>(); //sdk manifest files.Add(from + "/" + SDKManifest); //sdk lib string libDic = from + "/" + SDKLibDir; EditorPlatformPath.GetAllFilesRecursively(libDic, files); //sdk bin string binDir = from + "/" + SDKBinDir; EditorPlatformPath.GetAllFiles(binDir, files, ".jar"); //sdk assets string assetsDir = from + "/" + SDKAssetDir; EditorPlatformPath.GetAllFilesRecursively(assetsDir, files); //sdk res string resDir = from + "/" + SDKResDir; EditorPlatformPath.GetAllFilesRecursively(resDir, files); CopyToPublish(from, to, files); }
public static void CreateEntryXmlFile() { string path = AssetBundlePath.GetAssetBundleEntryPath(); if (File.Exists(path)) { File.Delete(path); } try { EditorPlatformPath.CheckDirExistsForFile(path); XmlDocument document = new XmlDocument(); XmlDeclaration dec = document.CreateXmlDeclaration("1.0", "UTF-8", null); XmlElement root = document.CreateElement("root"); document.AppendChild(root); XmlElement mapping = document.CreateElement("AssetMappings"); mapping.SetAttribute("manifest", AssetBundlePath.GetManifestAssetBundlePath()); root.AppendChild(mapping); XmlWriterSettings setting = new XmlWriterSettings(); setting.Indent = true; setting.Encoding = new UTF8Encoding(false); XmlWriter write = XmlWriter.Create(path, setting); document.Save(write); write.Flush(); write.Close(); } catch (Exception e) { Debug.LogError(e); } }
public static bool StartBuildAssetBundle(BuildTarget platform, bool isForceRebuild = false, bool onlyBuildLua = false) { AssetBundleBuildLuaUtil.CheckAndCreateLuaTempDir(); buildResultInfo = AssetBundleBuildParseUtil.GenarateAssetBundleBuildDatas(AssetBundleConfig.GetAllGroupInfos()); //暂时移除所有的已有bundle(即每次重新打包) //EditorFileOperate.RemoveDir(AssetBundlePath.GetAssetBundlePath()); //移除不存在的bundle资源文件与文件夹 RemoveNonexistAssetBundleFiles(); AssetBundleBuild[] needBuildFileList = buildResultInfo.ToBuildArray(); HashSet <string> onlyMoveFileList = buildResultInfo.onlyMoveFileList; EditorPlatformPath.CheckDirExists(AssetBundlePath.GetAssetBundlePath()); AssetBundleBuild[] realBuildFileList = needBuildFileList; if (onlyBuildLua) { List <AssetBundleBuild> tempList = new List <AssetBundleBuild>(); for (int i = 0; i < needBuildFileList.Length; i++) { if (needBuildFileList[i].assetBundleName.IndexOf(AssetBundlePath.LuaBundleNamePre) != -1) { tempList.Add(needBuildFileList[i]); } } realBuildFileList = tempList.ToArray(); } AssetBundleManifest manifest = BuildPipeline.BuildAssetBundles(AssetBundlePath.GetAssetBundlePath(), realBuildFileList, isForceRebuild ? BuildAssetBundleOptions.ForceRebuildAssetBundle : BuildAssetBundleOptions.None, platform); AssetBundleBuildLuaUtil.ClearLuaTempDir(); bool succ = true; if (manifest == null) { Debug.Log("BuildAssetBundle Fail!"); return(false); } //如果只打lua文件,不需要移动这些 if (!onlyBuildLua) { MoveFiles(onlyMoveFileList); MoveManifestAB(); } else { DeleteManifestAB(); } succ = succ && GenerateAssetBundleMappings(needBuildFileList); //MoveMainAssetBundle(); //ChageAssetBundleManifetDependToRelativePath(); AssetDatabase.Refresh(); if (succ) { Debug.Log("BuildAssetBundle Success!"); } else { Debug.Log("BuildAssetBundle Fail!"); } return(true); }