/// <summary> /// set update urls /// </summary> /// <param name="url"></param> /// <param name="platform"></param> private static void ResetUrls(string url, BuildPlatform platform) { if (url == null || url == "") { return; } TextAsset downloadUrlText = (TextAsset)Resources.Load("Urls"); BMUrls _bmUrl = JsonMapper.ToObject <BMUrls>(downloadUrlText.text); if (_bmUrl == null) { return; } if (platform == BuildPlatform.Android || platform == BuildPlatform.IOS || platform == BuildPlatform.Standalones) { _bmUrl.downloadUrls[platform.ToString()] = url; _bmUrl.backupDownloadUrls[platform.ToString()] = url; _bmUrl.bundleTarget = platform; string content = JsonFormatter.PrettyPrint(LitJson.JsonMapper.ToJson(_bmUrl)); string file_path = "Assets/BundleManager/Resources/Urls" + GameHelper.SETTING_FILE_EXTENSION; CustomTool.FileSystem.ReplaceFile(file_path, content); UnityEditor.AssetDatabase.ImportAsset(file_path); } }
//Unity Editor command line arguments //https://docs.unity3d.com/Manual/EditorCommandLineArguments.html public static void CommandLineBuild() { Debug.Log("[PackEditor]start build."); var platform = _buildPlatform.ToString(); var release = _isRelease ? "1" : "0"; var versionCode = $"{_buildVersionCode.ToString()}.{release}"; var channel = _buildChannel.ToString(); _buildOutputPath = $"{_buildOutputPath}/{platform}/{channel}/{versionCode}"; if (string.IsNullOrEmpty(_buildOutputPath)) { return; } if (Directory.Exists(_buildOutputPath)) { //Directory.Delete(_buildOutputPath, true); LogHelper.PrintError($"打包失败:版本已存在."); return; } Directory.CreateDirectory(_buildOutputPath); var extensionName = string.Empty; SwitchActiveBuildTarget(() => { BuildAssetBundle(); BuildPlayer(); }); }
public string GetInterpretedDownloadUrl(BuildPlatform platform, bool bUseBackup = false) { if (bUseBackup) { return(BMUtility.InterpretPath(backupDownloadUrls[platform.ToString()], platform)); } return(BMUtility.InterpretPath(downloadUrls[platform.ToString()], platform)); }
public void RefreshConfig(LocalizationType type, bool isDebug, BuildPlatform platform) { string isDebugStr = isDebug ? "_debug.xml" : "_release.xml"; //TODO Fix me string path = Application.dataPath + "/../../Settings/BuildSettings/jenkins_" + platform.ToString() + "_" + type.ToString() + isDebugStr; RefreshConfig(path); }
private static string EnvVarToString(string varString, BuildPlatform platform) { switch (varString) { case "DataPath": return(Application.dataPath); case "PersistentDataPath": return(Application.persistentDataPath); case "StreamingAssetsPath": return(Application.streamingAssetsPath); case "Platform": return(platform.ToString()); case "Personal": return(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal)); case "Version": return(EB.Version.GetVersion()); default: EB.Debug.LogError("Cannot solve environment var {0}", varString); return(""); } }
/// <summary> /// Generate AssetBundles and Generate version_file.bytes to AssetBundleServer Path /// </summary> public static void Generate(string relativePath, string poolPath, string serverPath, BuildPlatform platform) { // calculate assetbundle output path var platformPath = platform.ToString(); var bundleBuildPath = Path.Combine(poolPath, platformPath); if (Directory.Exists(bundleBuildPath)) { Directory.Delete(bundleBuildPath, true); } // build assetbundles and get manifest var manifest = BuildAssetBundles(bundleBuildPath); // calculate assetbundle server path var bundleCopyPath = Path.Combine(Path.Combine(Path.Combine(Application.dataPath, "StreamingAssets"), relativePath), platformPath); if (Directory.Exists(bundleCopyPath)) { Directory.Delete(bundleCopyPath, true); } // copy assetbundles to streamingAsset path CopyAssetBundles(manifest, bundleBuildPath, bundleCopyPath, platformPath, true); // generate VersionFile for streaming aseets GenerateVersionFile(manifest, relativePath, bundleCopyPath, platformPath, true); bundleCopyPath = Path.Combine(Path.Combine(serverPath, Settings.VersionNumber), platformPath); if (Directory.Exists(bundleCopyPath)) { Directory.Delete(bundleCopyPath, true); } // copy assetbundles to asset server path CopyAssetBundles(manifest, bundleBuildPath, bundleCopyPath, platformPath, false); // generate VersionFile for asset server GenerateVersionFile(manifest, relativePath, bundleCopyPath, platformPath, false); Debug.Log("Bundle Generate is Ok"); }
private static string EnvVarToString(string varString, BuildPlatform platform) { switch (varString) { case "DataPath": return(Application.dataPath); case "PersistentDataPath": return(Application.persistentDataPath); case "StreamingAssetsPath": return(Application.streamingAssetsPath); case "Platform": return(platform.ToString()); default: Debug.LogError("Cannot solve enviroment var " + varString); return(""); } }
public static void SetAssetBundleBuildOutput() { BuildPlatform build_platform = BuildConfiger.BundleBuildTarget; string build_target_string = build_platform.ToString(); //string build_output = Environment.GetFolderPath(Environment.SpecialFolder.Personal); string build_output = "$(Personal)"; string download_url = ""; // Joe Li: don't use '~', it only works in shell. build_output += "/LTSites/" + "$(Version)/$(Platform)"; download_url += build_target_string; if (BuildConfiger.BuildOutputStr != build_output || DownloadConfiger.downloadUrl != download_url) { DownloadConfiger.downloadUrl = download_url; BuildConfiger.BuildOutputStr = build_output; EB.Debug.Log("Output: {0}=>{1}", build_output, BuildConfiger.InterpretedOutputPath); EB.Debug.Log("Download: {0}", download_url); } }
public string GetInterpretedOutputPath(BuildPlatform platform) { return(BMUtility.InterpretPath(outputs[platform.ToString()], platform)); }
public string GetInterpretedDownloadUrl(BuildPlatform platform) { return(BMUtility.InterpretPath(downloadUrls[platform.ToString()], platform)); }
/// <summary> /// 得到Manifest的名字 /// </summary> public string GetManifestName() { return(CurBuildPlatform.ToString() + "_Assetbundles"); }
/// <summary> /// 应用当前Bundle配置打包生成所有的Bundle /// </summary> public static void Publish(bool bQuick = false) { BuildTarget target = BuildTarget.Android; BuildPlatform platform = BuildPlatform.Android; string rootPath = ProjectBuildHelper.GetSaveBundlePath(target, platform); //build lua scripts DefinedMacro.FGameMacro macro = null; TextAsset ass = Resources.Load("DefinedMacro", typeof(TextAsset)) as TextAsset; if (ass != null) { macro = LitJson.JsonMapper.ToObject <DefinedMacro.FGameMacro>(ass.text); } bool bUseLuajit = false; bool bCompressedBundle = true; if (macro != null) { bUseLuajit = macro.bUseLuajit; bCompressedBundle = macro.bCompressedBundle; } UpdateLuaScripts(bUseLuajit); //if we have one update server. skip this string url = rootPath + "/Compressed"; ResetUrls(url, platform); UpdateBundleManager(); string outpath = rootPath + "/tmp"; if (Directory.Exists(outpath)) { Directory.Delete(outpath, true); } Directory.CreateDirectory(outpath); AssetDatabase.Refresh(); UnityEngine.Debug.Log("Build bundle for " + platform.ToString()); DoMakeBundle(outpath, target); MakeBMFile(outpath); string[] AllBundles = AssetDatabase.GetAllAssetBundleNames(); string tmp = outpath.Substring(0, outpath.LastIndexOf("/")) + "/Bundle_Latest"; if (Directory.Exists(tmp)) { if (bCompressedBundle) { BackupLuaBundleFile(tmp); } } else { Directory.CreateDirectory(tmp); } foreach (var Bundle in AllBundles) { string BundlePath = tmp + "/" + Bundle; if (!Directory.Exists(Path.GetDirectoryName(BundlePath))) { FileSystem.CreatePath(Path.GetDirectoryName(BundlePath)); } if (File.Exists(outpath + "/" + Bundle)) { FileUtil.ReplaceFile(outpath + "/" + Bundle, BundlePath); } else { UnityEngine.Debug.LogError("Failed cooking bundle:: " + Bundle); } } if (bCompressedBundle) { SimpleLZMA.CompressFiles(outpath, true, false); } else { SimpleLZMA.CompressFile(outpath, true); } checkBundleBinary.Clear(); backOldBundleBinary.Clear(); cookingSetting = null; if (File.Exists("Assets/Resources/GameBundle.txt")) { File.Delete("Assets/Resources/GameBundle.txt"); } //create game config UpdateGameBundlesConfig(rootPath); EditorUtility.DisplayDialog("提示", "打包工作已完成,请检测输出已确定成功打包!", "确定"); }
public string GetInterpretedOutputPath(BuildPlatform platform) { return BMUtility.InterpretPath(this.outputs[platform.ToString()], platform); }
public string GetInterpretedDownloadUrl(BuildPlatform platform) { return BMUtility.InterpretPath(this.downloadUrls[platform.ToString()], platform); }
private static string EnvVarToString(string varString, BuildPlatform platform) { switch (varString) { case "DataPath": return Application.dataPath; case "PersistentDataPath": return Application.persistentDataPath; case "StreamingAssetsPath": return Application.streamingAssetsPath; case "Platform": return platform.ToString(); case "BundlePath": return EditorConfig.Instance.BundlePath; case "Localization": return JenkinsBuildConfig.Instance.Language.ToString(); case "BundleVersion": return JenkinsBuildConfig.Instance.Bundleversion; default: Debug.LogError("Cannot solve enviroment var " + varString); return ""; } }