private async void BuildMod() { var scene = EditorSceneManager.GetActiveScene(); EditorUtility.DisplayProgressBar("ModPlayerSDK", "Building...", 0); UniMigration.MigrateAll(); AssetImporter.GetAtPath(scene.path) .SetAssetBundleNameAndVariant($"{modName}_scene", ""); BundleResources.SetAssetBundleAllResources($"{modName}_script"); MergeCsx.CreateMonolith( "Assets/modplayer_script.json", $"{modName}_script"); UniAssetBundle.BuildUniScriptScene( $"{modName}_scene", $"{modName}_script"); UniMigration.EndMigration(); EditorUtility.DisplayProgressBar("ModPlayerSDK", "Uploading...", 0); await UploadMod(); EditorUtility.ClearProgressBar(); }
public static void BuildUniScriptScene(string sceneBundleName, string assetBundleName) { //if (Directory.Exists("Packs")) // Directory.Delete("Packs", true); Directory.CreateDirectory("Packs"); var monolithPath = "Assets/UniScript/Resources/uniscript_monolith.json"; MergeCsx.CreateMonolith(monolithPath, assetBundleName); var resourceMapPath = "Assets/UniScript/Resources/uniscript_resource_map.json"; var resourceMap = UniMigration.GenerateResourceMap(); File.WriteAllText(resourceMapPath, JsonConvert.SerializeObject(resourceMap)); AssetDatabase.ImportAsset(resourceMapPath); AssetImporter.GetAtPath(resourceMapPath).SetAssetBundleNameAndVariant(assetBundleName, ""); var randId = System.DateTime.Now.GetHashCode().ToString(); var mf = BuildPipeline.BuildAssetBundles("./Packs/", BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows64); foreach (var name in mf.GetAllAssetBundles()) { var hash = mf.GetAssetBundleHash(name); var id = name; var bundleData = new BundleData() { hash = hash.ToString(), id = id }; File.WriteAllText("./Packs/" + name + ".json", JsonUtility.ToJson(bundleData)); } File.Delete(monolithPath); File.Delete(resourceMapPath); }