public static void GenerateVersionInfo(BuildTarget buildTarget, int versionCode = 0) { if (versionCode == 0) { versionCode = GameVersion.code; } GameConfig.VersionInfo version = new GameConfig.VersionInfo(versionCode); string mainifestPath = Path.Combine(XManifest.updateRenameResOutputPath, XManifest.name); if (File.Exists(mainifestPath)) { version.ManifestChecksum = GHelper.ComputeFileChecksum(mainifestPath); } version.ResRoot = "http://cdn-tf02.dev.tapenjoy.com/"; version.ResRootPublish = "http://lf3-ma18cdn-cn.dailygn.com/obj/light-game-cn/ma18/tf02/"; string content = LitJson.JsonMapper.ToJson(version); Debug.Log(string.Format("version content: {0}", content)); string path = Path.Combine(Environment.CurrentDirectory, string.Format("build/ver/{0}", XManifest.GetPlatformFolder(EditorUserBuildSettings.activeBuildTarget))); if (Directory.Exists(path)) { Directory.Delete(path, true); } Directory.CreateDirectory(path); string name = Path.Combine(path, "ver.txt"); Debug.Log(String.Format("version file save at: {0}", name)); try { FileStream fs = new FileStream(name, FileMode.Create); System.Text.UTF8Encoding utf8 = new System.Text.UTF8Encoding(false); StreamWriter sw = new StreamWriter(fs, utf8); sw.Write(content); sw.Close(); fs.Close(); } catch (IOException e) { Debug.Log(e.Message); } //GenerateShareConfigJson(version.GetVersionCode()); GenerateInnerVersionInfo(buildTarget, versionCode); }
public static void GenerateShareConfigJson(int versionCode) { GameConfig.VersionInfo version = new GameConfig.VersionInfo(versionCode); Hashtable ht = new Hashtable(); ht.Add("androidSchema", "fruitapp://com.guangyue.tf02.android"); ht.Add("link", "https://cdn-tf02-tt.tapenjoy.com/fruit_tower/open"); ht.Add("iosSchema", "fruitapp://"); ht.Add("androidDownload", "http://lf3-ma18cdn-cn.dailygn.com/obj/light-game-cn/ma18/tf02/android/tower_v" + version.MainVersion + "_" + version.SubVersion + ".apk"); ht.Add("iosDownload", "http://itunes.apple.com/cn/app/id1520151694?mt=8"); string result = MiniJSON.jsonEncode(ht); File.WriteAllText("share/cfg_share.json", result); }
static void XManifestSave(string path, bool pretty = true) { GameConfig.VersionInfo version = new GameConfig.VersionInfo(VersionCode); XManifest.Instance.Save(path, pretty, version.MainVersion, version.SubVersion); }
public static void GenerateFileAllocationTable(BuildTarget buildTarget) { string targetName = XManifest.GetPlatformFolder(buildTarget); string bundlePath = assetBundleOutputPath; EditorUtility.DisplayProgressBar("Generate Manifest", "loading bundle manifest", 1 / 2); AssetBundle bundle = AssetBundle.LoadFromFile(Path.Combine(bundlePath, targetName)); if (bundle == null) { Debug.LogError("Build Resrouce First."); EditorUtility.ClearProgressBar(); return; } XManifest.Instance.Clear(); try { string manifestSavePath = XManifest.manifestOutputPath; // gen packs AssetBundleManifest manifest = bundle.LoadAsset <AssetBundleManifest>("AssetBundleManifest"); string[] bundles = manifest.GetAllAssetBundles(); EditorUtility.DisplayProgressBar("Generate Manifest", "compute bundle hash", 0); for (int i = 0; i < bundles.Length; i++) { string bundleName = bundles[i]; XManifest.Pack pack = new XManifest.Pack(); pack.name = bundleName; uint checksum = 0; uint size = 0; GetFileInfo(Path.Combine(bundlePath, bundleName), out checksum, out size); pack.checksum = checksum; pack.size = size; pack.location = XManifest.Location.Streaming; //pack.preloadType = XManifest.PreloadType.Loading; List <string> dependencies = new List <string>(manifest.GetAllDependencies(bundleName)); dependencies.Remove(bundleName); pack.dependencies = dependencies.ToArray(); XManifest.Instance.Add(pack); foreach (string file in AssetDatabase.GetAssetPathsFromAssetBundle(bundleName)) { if (Path.GetExtension(file) == ".unity") // gen scenes { XManifest.Scene scene = new XManifest.Scene(); scene.name = Path.GetFileNameWithoutExtension(file); scene.bundle = bundleName; XManifest.Instance.Add(scene); } else if (Path.GetExtension(file) == ".spriteatlas") // gen sporitepack { var name = Path.GetFileNameWithoutExtension(file); if (XManifest.Instance.GetSpritePack(name) != null) { throw new System.Exception("can't have mutip spriteatlas named:" + file); } List <string> allPackable = new List <string>(); var sa = AssetDatabase.LoadAssetAtPath <UnityEngine.U2D.SpriteAtlas>(file); var textureNameMap = new Dictionary <string, bool>(); foreach (var pa in UnityEditor.U2D.SpriteAtlasExtensions.GetPackables(sa)) { var assetPath = AssetDatabase.GetAssetPath(pa.GetInstanceID()); assetPath = assetPath.Replace(Defines.AssetBundleSourcePath + "/", null); assetPath = Path.ChangeExtension(assetPath, null); allPackable.Add(assetPath); } XManifest.SpritePack spritePack = new XManifest.SpritePack(); spritePack.name = name; spritePack.packable = allPackable.ToArray(); var realName = file.Replace(Defines.AssetBundleSourcePath + "/", null).ToLower().Replace("\\", "/"); if (System.IO.Path.HasExtension(realName)) { realName = System.IO.Path.ChangeExtension(realName, null); } spritePack.realName = realName; XManifest.Instance.Add(spritePack); } } EditorUtility.DisplayProgressBar("Generate Manifest", "compute bundle hash", i / (float)bundles.Length); } // record luas List <string> luaFiles = new List <string>(); GetAllFile(new DirectoryInfo(Defines.LuaByteCodeOutPath), luaFiles); foreach (string fileName in luaFiles) { string name = Path.GetFileNameWithoutExtension(fileName); if (!XManifest.Instance.Exists(name)) { XManifest.File file = new XManifest.File(); file.name = name; file.location = XManifest.Location.Streaming; uint checksum = 0; uint size = 0; GetFileInfo(fileName, out checksum, out size); file.checksum = checksum; file.size = size; XManifest.Instance.Add(file); } else { Debug.LogError("[GenerateFileAllocationTable] repeat name:" + name); } } // gen rules BundleNameHelper.initPackRules(); foreach (BundlePackRule rule in BundleNameHelper.rules) { XManifest.Instance.AddBundleRule(rule); } GameConfig.VersionInfo version = new GameConfig.VersionInfo(VersionCode); XManifestSave(manifestSavePath, true); Debug.Log("[GenerateFileAllocationTable] Mainfest 生成成功:" + manifestSavePath); } catch (System.Exception e) { Debug.LogException(e); } EditorUtility.DisplayProgressBar("Generate Manifest", "success!", 1.0f); bundle.Unload(true); EditorUtility.ClearProgressBar(); AssetDatabase.Refresh(); }