/// <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 }
void OnDisable() { if (changedCount > 0) { DefinedMacro.FGameMacro _macro = new DefinedMacro.FGameMacro(); for (int i = 0; i < _list.Count; ++i) { if (_list[i].macro == USE_BUNDLE_KEY) { _macro.bUseBundle = _list[i].value; } else if (_list[i].macro == USE_LUAJIT) { _macro.bUseLuajit = _list[i].value; } else if (_list[i].macro == ENABLED_LOGS) { _macro.bLogEnabled = _list[i].value; } else if (_list[i].macro == SKIP_CHECK_APK) { _macro.bSkipCheckAPK = _list[i].value; } else if (_list[i].macro == GAME_TYPE) { _macro.gameType = _list[i].gameType; } else if (_list[i].macro == BUNDLE_COMPRESSED) { _macro.bCompressedBundle = _list[i].value; } else if (_list[i].macro == SKIP_UPDATE) { _macro.bSkipUpdate = _list[i].value; } else if (_list[1].macro == USE_WECHAT) { _macro.bWithWeChat = _list[i].value; } } // Debug.Log(_macro.bSkipUpdate); string content = JsonFormatter.PrettyPrint(LitJson.JsonMapper.ToJson(_macro)); CustomTool.FileSystem.ReplaceFile(TARGET_GAME_MACRO_FILE + GameHelper.SETTING_FILE_EXTENSION, content); UnityEditor.AssetDatabase.ImportAsset(TARGET_GAME_MACRO_FILE + GameHelper.SETTING_FILE_EXTENSION); } changedCount = 0; _saved.Clear(); _list.Clear(); _savedGameType.Clear(); }
public static void OpenGameMacroWin() { if (File.Exists(PATH_OF_MACRO_TEMPLATE) == false) { MakeMacroTemplate(); } TextAsset asset = AssetDatabase.LoadAssetAtPath(PATH_OF_MACRO_TEMPLATE, typeof(TextAsset)) as TextAsset; if (asset == null) { Debug.LogError("Failed to load " + PATH_OF_MACRO_TEMPLATE); } else { string text = asset.text; _list = LitJson.JsonMapper.ToObject <List <FGameMacroListItem> >(text); DefinedMacro.FGameMacro _macro = new DefinedMacro.FGameMacro(); if (File.Exists(TARGET_GAME_MACRO_FILE + GameHelper.SETTING_FILE_EXTENSION)) { TextAsset ass = Resources.Load("DefinedMacro", typeof(TextAsset)) as TextAsset; _macro = LitJson.JsonMapper.ToObject <DefinedMacro.FGameMacro>(ass.text); } _saved.Clear(); for (int i = 0; i < _list.Count; ++i) { if (_list[i].macro == USE_BUNDLE_KEY) { _list[i].value = _macro.bUseBundle; } else if (_list[i].macro == USE_LUAJIT) { _list[i].value = _macro.bUseLuajit; } else if (_list[i].macro == ENABLED_LOGS) { _list[i].value = _macro.bLogEnabled; } else if (_list[i].macro == SKIP_CHECK_APK) { _list[i].value = _macro.bSkipCheckAPK; } else if (_list[i].macro == SKIP_UPDATE) { _list[i].value = _macro.bSkipUpdate; } else if (_list[i].macro == GAME_TYPE) { _list[i].gameType = _macro.gameType; _savedGameType.Add(_list[i].title, _list[i].gameType); continue; } else if (_list[i].macro == BUNDLE_COMPRESSED) { _list[i].value = _macro.bCompressedBundle; } else if (_list[i].macro == USE_WECHAT) { _list[i].value = _macro.bWithWeChat; } _saved.Add(_list[i].title, _list[i].value); } changedCount = 0; } games.Clear(); games.AddRange(new string[] { "Fish", "Fish2d", "NiuNiu", "BlackJack", "Baccarat", "ShuiHuZhuan", "MAX" }); GetWindow <GameMacroWindow>(true, "Define Game Macro", true); }
/// <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("提示", "打包工作已完成,请检测输出已确定成功打包!", "确定"); }