/// <summary> /// register symbols /// </summary> /// <param name="bRawres"> whether we can define RAW_RES symbols</param> /// <param name="group"> build platform</param> /// <param name="bNoLog"> with log??</param> public static void RegisterSymbols(FBuildParam inParam) { if (inParam == null) { Debug.LogError("Failed to register game macro"); return; } #region force compress bundle when cooking distribution app TextAsset ass = Resources.Load("DefinedMacro", typeof(TextAsset)) as TextAsset; DefinedMacro.FGameMacro _macro = new DefinedMacro.FGameMacro(); _macro = LitJson.JsonMapper.ToObject <DefinedMacro.FGameMacro>(ass.text); _macro.bCompressedBundle = inParam.bCompressedBundle; _macro.bSkipUpdate = inParam.bSkipUpdate; _macro.bUseLuajit = inParam.bUseLuajit; _macro.bSkipCheckAPK = inParam.bSkipCheckAPK; _macro.bLogEnabled = inParam.bDevelopment; _macro.bUseBundle = true; _macro.bWithWeChat = inParam.bWithWeChat; string content = JsonFormatter.PrettyPrint(LitJson.JsonMapper.ToJson(_macro)); string file_path = "Assets/Resources/DefinedMacro" + GameHelper.SETTING_FILE_EXTENSION; Debug.Log("Macro:: " + content); CustomTool.FileSystem.ReplaceFile(file_path, content); UnityEditor.AssetDatabase.ImportAsset(file_path); UnityEditor.AssetDatabase.Refresh(); #endregion }
public static void ResetPlayerSettings(FBuildParam inParam) { if (inParam.platform == BuildPlatform.IOS) { #region overwrited optimization setting //these setting help us to build the minimum binary file PlayerSettings.strippingLevel = StrippingLevel.StripAssemblies; PlayerSettings.SetApiCompatibilityLevel(BuildTargetGroup.iOS, ApiCompatibilityLevel.NET_2_0_Subset); PlayerSettings.iOS.scriptCallOptimization = ScriptCallOptimizationLevel.SlowAndSafe; //force allow automatic rotate to portrait for trying to solve ITMS-90474 PlayerSettings.allowedAutorotateToPortrait = true; PlayerSettings.allowedAutorotateToPortraitUpsideDown = true; PlayerSettings.defaultInterfaceOrientation = UIOrientation.LandscapeLeft; AssetDatabase.SaveAssets(); PlayerSettings.bundleVersion = inParam.bundleVersion.ToString(); PlayerSettings.iOS.buildNumber = inParam.bundleVersion.ToString(); #endregion //support 64-bit machine. It can solve the link error when build the ios application. //This is the standard setting for ios platform. The most improvement way for link error is //split the large module file or put sdk into the plugin directory. Because files will be //push into new dll file. So it indicates that we can avoid link error with this way. PlayerSettings.SetScriptingBackend(BuildTargetGroup.iOS, ScriptingImplementation.IL2CPP); PlayerSettings.iOS.targetDevice = iOSTargetDevice.iPhoneAndiPad; UpdateGameVersion(inParam.platform); } else if (inParam.platform == BuildPlatform.Android) { #region overwrited optimization setting //these setting help us to build the minimum binary file PlayerSettings.strippingLevel = StrippingLevel.StripAssemblies; PlayerSettings.SetApiCompatibilityLevel(BuildTargetGroup.Android, ApiCompatibilityLevel.NET_2_0_Subset); PlayerSettings.allowedAutorotateToPortrait = false; PlayerSettings.allowedAutorotateToPortraitUpsideDown = false; PlayerSettings.Android.forceSDCardPermission = true; PlayerSettings.Android.forceInternetPermission = true; #endregion #region update build version PlayerSettings.bundleVersion = inParam.bundleVersion.ToString(); UpdateGameVersion(inParam.platform); #endregion } else if (inParam.platform == BuildPlatform.Standalones) { #region overwrited optimization setting //these setting help us to build the minimum binary file PlayerSettings.strippingLevel = StrippingLevel.StripByteCode; PlayerSettings.SetApiCompatibilityLevel(BuildTargetGroup.Standalone, ApiCompatibilityLevel.NET_2_0_Subset); PlayerSettings.SetGraphicsAPIs(BuildTarget.StandaloneWindows, new UnityEngine.Rendering.GraphicsDeviceType[1] { UnityEngine.Rendering.GraphicsDeviceType.Direct3D9 }); #endregion } else { Debug.LogError(string.Format("Currently do not support {0} platform", inParam.platform.ToString())); return; } PlayerSettings.productName = inParam.displayName; AssetDatabase.SaveAssets(); }
/// <summary> /// build bundles /// </summary> /// <param name="param"></param> public static void BuildBundles(FBuildParam param) { string finalSavePath = ""; finalSavePath = param.savePath; //always cooking all bundles //if((EGameType) param.gameType == EGameType.EGT_MAX) //{ focusGame = (int)EGameBundle.EGB_ALL; //} //else //{ // focusGame = param.gameType; //} UpdateLuaScripts(false); //if we have one update server. skip this string url = param.savePath + "/Compressed"; ResetUrls(url, param.platform); //load bundle asset path LoadBundleAssetPath(); UnityEngine.Debug.Log("finalSavePath=" + finalSavePath); if (!Directory.Exists(finalSavePath)) { Directory.CreateDirectory(finalSavePath); } string Folder = finalSavePath + "/tmp"; string outputPath = Folder; if (Directory.Exists(outputPath)) { foreach (string file in Directory.GetFiles(outputPath)) { File.Delete(file); UnityEngine.Debug.Log("Remove " + file); } } UnityEngine.Debug.Log("outputPath=" + outputPath); AssetDatabase.Refresh(); if (param.type != EBuildType.EBT_BundleQuick) { UpdateBundleManager(); } //ensure output directory is exist if (!Directory.Exists(outputPath)) { Directory.CreateDirectory(outputPath); } DoMakeBundle(outputPath, EditorUserBuildSettings.activeBuildTarget); //fresh asset data base AssetDatabase.Refresh(); //remove unused asset bundle AssetDatabase.RemoveUnusedAssetBundleNames(); //build bundle manager bundle file MakeBMFile(outputPath); string[] AllBundles = AssetDatabase.GetAllAssetBundleNames(); string original_path = finalSavePath + "/Bundle_Basic"; if (param.type == EBuildType.EBT_Bundle || param.type == EBuildType.EBT_BundleApp) { if (Directory.Exists(original_path)) { FileUtil.DeleteFileOrDirectory(original_path); } finalSavePath = original_path; } else { finalSavePath += "/Bundle_Latest"; } UnityEngine.Debug.Log("finalSavePath=" + finalSavePath); //ensure path is exist if (Directory.Exists(finalSavePath) == false) { Directory.CreateDirectory(finalSavePath); } //quick means dlc? if (param.type == EBuildType.EBT_BundleQuick) { BackupLuaBundleFile(finalSavePath); } foreach (var Bundle in AllBundles) { string BundlePath = finalSavePath + "/" + Bundle; if (!Directory.Exists(Path.GetDirectoryName(BundlePath))) { FileSystem.CreatePath(Path.GetDirectoryName(BundlePath)); } if (File.Exists(Folder + "/" + Bundle)) { FileUtil.ReplaceFile(Folder + "/" + Bundle, BundlePath); } else { UnityEngine.Debug.LogError("Failed cooking bundle:: " + Bundle); } } UnityEngine.Debug.Log("Now compressing bundle:: parameter is :: " + param.ToString()); //copy bm.data if (File.Exists(Folder + "/bm.data")) { FileUtil.ReplaceFile(Folder + "/bm.data", finalSavePath + "/bm.data"); } if (param.bCompressedBundle) { //now compress bundle files; if (param.type == EBuildType.EBT_Bundle || param.type == EBuildType.EBT_BundleQuick || param.type == EBuildType.EBT_BundleApp) { UnityEngine.Debug.Log("Compressing dlc bundle"); bool bCopy = false; if (param.type == EBuildType.EBT_BundleApp) { bCopy = true; } //开始压缩 if (param.type == EBuildType.EBT_BundleQuick) { SimpleLZMA.CompressFiles(finalSavePath, bCopy, true); } else { SimpleLZMA.CompressFiles(finalSavePath, bCopy); } //now delete the lateset files; // Directory.Delete(finalSavePath, true); } } else { SimpleLZMA.CompressFile(finalSavePath, true); } backOldBundleBinary.Clear(); checkBundleBinary.Clear(); cookingSetting = null; UpdateGameBundlesConfig(param.savePath + "/Compressed"); AssetDatabase.Refresh(); }