/// <summary> /// 构建dll /// </summary> public static void BuildDLL() { //检查打包脚本 EditorWindow_ScriptBuildDll.RoslynBuild(outputPath, RuntimePlatform.Android, ScriptBuildTools.BuildMode.Release); //检查下打包前的代码错 BuildPipeline.BuildAssetBundles(Application.streamingAssetsPath, BuildAssetBundleOptions.DeterministicAssetBundle, BuildTarget.Android); }
/// <summary> /// 生成所有资源 /// </summary> /// <param name="exportPath"></param> /// <param name="platform"></param> /// <param name="target"></param> static public void GenAllAssets(string exportPath, RuntimePlatform platform, BuildTarget target) { var outPath = exportPath + "/" + BDUtils.GetPlatformPath(platform); if (Directory.Exists(outPath)) { Directory.Delete(outPath, true); } //1.打包资源 try { AssetBundleEditorTools.GenAssetBundle("Resource/Runtime/", outPath, target); } catch (Exception e) { Debug.LogError(e.Message); return; } //2.编译脚本 try { ScriptBuildTools.BuildDll(Application.dataPath, outPath, ScriptBuildTools.BuildMode.Release); var targetPath = Application.streamingAssetsPath + "/" + BDUtils.GetPlatformPath(platform) + "/hotfix/hotfix.dll"; var hotFix = outPath + "/hotfix/hotfix.dll"; //防空 if (!Directory.Exists(Path.GetDirectoryName(targetPath))) { Directory.CreateDirectory(Path.GetDirectoryName(targetPath)); } //拷贝 if (hotFix != targetPath) { if (File.Exists(targetPath)) { File.Delete(targetPath); } File.Copy(hotFix, targetPath, true); } //分析 EditorWindow_ScriptBuildDll.GenCLRBindingByAnalysis(platform); } catch (Exception e) { Debug.LogError(e.Message); return; } //3.打包表格 try { Excel2SQLiteTools.GenSQLite(outPath); Excel2SQLiteTools.CopyCurrentSqlToOther(outPath); } catch (Exception e) { Debug.LogError(e.Message); } }
static void Exprot() { var targetPath = "Assets/Code/BDFramework.Game/ILRuntime/Binding/Analysis"; //1.分析之前先删除,然后生成临时文件防止报错 if (Directory.Exists(targetPath)) { Directory.Delete(targetPath, true); } var fileContent = @" namespace ILRuntime.Runtime.Generated { class CLRBindings { internal static ILRuntime.Runtime.Enviorment.ValueTypeBinder<UnityEngine.Vector2> s_UnityEngine_Vector2_Binding_Binder = null; internal static ILRuntime.Runtime.Enviorment.ValueTypeBinder<UnityEngine.Vector3> s_UnityEngine_Vector3_Binding_Binder = null; internal static ILRuntime.Runtime.Enviorment.ValueTypeBinder<UnityEngine.Vector4> s_UnityEngine_Vector4_Binding_Binder = null; internal static ILRuntime.Runtime.Enviorment.ValueTypeBinder<UnityEngine.Quaternion> s_UnityEngine_Quaternion_Binding_Binder = null; public static void Initialize(ILRuntime.Runtime.Enviorment.AppDomain app) { } } } "; FileHelper.WriteAllText(targetPath + "/CLRBindings.cs", fileContent); AssetDatabase.Refresh(); var exporterDirectoryList = new string[] { "Assets/3rdPlugins/Dotween", // 第三方查件 "Assets/Code/BDFramework.Game", //Game "Assets/Scenes", //Scene "Assets/Packages", //Nuget }; var exportAssets = new List <string>(); foreach (var direct in exporterDirectoryList) { var fs = Directory.GetFiles(direct, "*.*", SearchOption.AllDirectories); exportAssets.AddRange(fs); } var exportfs = exportAssets.Where((ex) => !ex.EndsWith(".meta")).ToArray(); //版本信息添加 var path = AssetDatabase.GUIDToAssetPath("924d970067c935c4f8b818e6b4ab9e07"); File.WriteAllText(path, BDEditorApplication.BDFrameConfig.Version); AssetDatabase.Refresh(); //导出 ExportPackageOptions op = ExportPackageOptions.Default; var packagePath = AssetDatabase.GUIDToAssetPath("69227cf6ea5304641ae95ffb93874014"); //AssetDatabase.ImportPackage(packagePath,true); AssetDatabase.ExportPackage(exportfs, packagePath, op); //重新生成clr分析文件 EditorWindow_ScriptBuildDll.GenCLRBindingByAnalysis(); //debug Debug.Log("导出成功:" + packagePath); }
public void Show() { this.editorTable = new EditorWindow_Table(); this.editorAsset = new EditorWindow_GenAssetBundle(); this.editorScript = new EditorWindow_ScriptBuildDll(); this.minSize = this.maxSize = new Vector2(1050, 600); base.Show(); }
public void Show() { this.editorTable = new EditorWindow_Table(); this.editorAsset = new EditorWindow_BuildAssetBundle(); this.editorScript = new EditorWindow_ScriptBuildDll(); EXPORT_PATH = BApplication.DevOpsPublishAssetsPath; this.minSize = this.maxSize = new Vector2(1000, 800); base.Show(); }
static private void BuildHotfixDll() { //编译dll if (BDAssetImporterCache.IsChangedHotfixCode && //修改过Hotfix BDFrameEditorConfigHelper.EditorConfig.BuildAssetConfig.IsAutoBuildDll) { EditorWindow_ScriptBuildDll.RoslynBuild(Application.streamingAssetsPath, Application.platform, ScriptBuildTools.BuildMode.Debug, false); Debug.Log("自动编译Hotfix.dll成功!"); } }
/// <summary> /// 生成所有资源 /// </summary> /// <param name="outputPath"></param> /// <param name="platform"></param> /// <param name="target"></param> static public void GenAllAssets(string outputPath, RuntimePlatform platform, BuildTarget target) { var _outputPath = Path.Combine(outputPath, BDApplication.GetPlatformPath(platform)); // + "/" + ; if (Directory.Exists(_outputPath)) { Directory.Delete(_outputPath, true); } _outputPath = null; //1.打包资源 try { //1.搜集keywork ShaderCollection.GenShaderVariant(); //2.打包模式 var config = BDFrameEditorConfigHelper.EditorConfig.AssetConfig; AssetBundleEditorToolsV2.GenAssetBundle(outputPath, platform, target, BuildAssetBundleOptions.ChunkBasedCompression, config.IsUseHashName, config.AESCode); } catch (Exception e) { Debug.LogError(e.Message); return; } //2.编译脚本 try { EditorWindow_ScriptBuildDll.RoslynBuild(outputPath, platform, ScriptBuildTools.BuildMode.Release); } catch (Exception e) { Debug.LogError(e.Message); return; } //3.打包表格 try { Excel2SQLiteTools.ALLExcel2SQLite(outputPath, platform); } catch (Exception e) { Debug.LogError(e.Message); } }
/// <summary> /// 热更代码发生改变 /// </summary> static public void OnCodeChanged() { //获取最近修改的代码 var codes = BDEditorApplication.GetLeastHotfixCodes(); if (codes != null && codes.Length > 0) //修改过Hotfix { if (BDEditorApplication.BDFrameWorkFrameEditorSetting.BuildSetting.IsNeedAutoBuildDll()) { EditorWindow_ScriptBuildDll.RoslynBuild(Application.streamingAssetsPath, BApplication.RuntimePlatform, ScriptBuildTools.BuildMode.Debug, false); Debug.Log("自动编译Hotfix.dll成功!"); } else if (BDEditorApplication.BDFrameWorkFrameEditorSetting.BuildSetting.IsHotfixCodeOutofUnityAssets()) { MoveCodeToBDWorkSpace(codes); } } }
/// <summary> /// 一键build所有资源 /// </summary> public static void OneKeyBuildALLAssets_ForBuildPackage(RuntimePlatform platform, string outpath) { var outPath = outpath + "/" + BDUtils.GetPlatformPath(platform); //1.编译脚本 ScriptBuildTools.BuildDll(Application.dataPath, outPath); EditorWindow_ScriptBuildDll.GenCLRBindingByAnalysis(platform); //2.打包资源 if (platform == RuntimePlatform.IPhonePlayer) { AssetBundleEditorTools.GenAssetBundle("Resource/Runtime/", outPath, BuildTarget.iOS); } else if (platform == RuntimePlatform.Android) { AssetBundleEditorTools.GenAssetBundle("Resource/Runtime/", outPath, BuildTarget.Android); } //3.打包表格 Excel2SQLiteTools.GenSQLite(outPath); }
/// <summary> /// 生成所有资源 /// </summary> /// <param name="exportPath"></param> /// <param name="platform"></param> /// <param name="target"></param> static public void GenAllAssets(string exportPath, RuntimePlatform platform, BuildTarget target) { var outPath = exportPath + "/" + BDUtils.GetPlatformPath(platform); if (Directory.Exists(outPath)) { Directory.Delete(outPath, true); } //1.打包资源 try { AssetBundleEditorTools.GenAssetBundle("Resource/Runtime/", outPath, target); } catch (Exception e) { Debug.LogError(e.Message); return; } //2.编译脚本 try { var targetPath = exportPath + "/" + BDUtils.GetPlatformPath(platform); EditorWindow_ScriptBuildDll.RoslynBuild(ScriptBuildTools.BuildMode.Release, targetPath); } catch (Exception e) { Debug.LogError(e.Message); return; } //3.打包表格 try { Excel2SQLiteTools.GenSQLite(outPath); Excel2SQLiteTools.CopyCurrentSqlToOther(outPath); } catch (Exception e) { Debug.LogError(e.Message); } }
/// <summary> /// 生成所有资源 /// </summary> /// <param name="exportPath"></param> /// <param name="platform"></param> /// <param name="target"></param> static public void GenAllAssets(string exportPath, RuntimePlatform platform, BuildTarget target) { var outPath = exportPath + "/" + BApplication.GetPlatformPath(platform); if (Directory.Exists(outPath)) { Directory.Delete(outPath, true); } //1.打包资源 try { //搜集keywork ShaderCollection.GenShaderVariant(); AssetBundleEditorTools.GenAssetBundle(outPath, target); } catch (Exception e) { Debug.LogError(e.Message); return; } //2.编译脚本 try { EditorWindow_ScriptBuildDll.RoslynBuild(ScriptBuildTools.BuildMode.Release, outPath); } catch (Exception e) { Debug.LogError(e.Message); return; } //3.打包表格 try { Excel2SQLiteTools.GenExcel2SQLite(exportPath, platform); } catch (Exception e) { Debug.LogError(e.Message); } }
/// <summary> /// 构建包体 /// </summary> static private void BuildPackage(RuntimePlatform platform, EditorBuildPackage.BuildMode buildMode) { //1.下载资源已有、Sql var ret = DownloadFormFileServer(platform); //2.打包dll ScriptBuildTools.BuildMode mode = buildMode == EditorBuildPackage.BuildMode.Debug ? ScriptBuildTools.BuildMode.Debug : ScriptBuildTools.BuildMode.Release; EditorWindow_ScriptBuildDll.RoslynBuild(outputPath, platform, mode); //3.构建空包即可 if (!ret) { //构建资源 if (platform == RuntimePlatform.Android) { BuildAssetBundle(RuntimePlatform.Android, BuildTarget.Android); } else if (platform == RuntimePlatform.IPhonePlayer) { BuildAssetBundle(RuntimePlatform.IPhonePlayer, BuildTarget.iOS); } } //加载配置 EditorBuildPackage.LoadConfig(buildMode); // if (platform == RuntimePlatform.Android) { EditorBuildPackage.BuildAPK(buildMode); //上传APK UploadAPK(); } else if (platform == RuntimePlatform.IPhonePlayer) { //测试构建 // BuildTest.BuildIPA(); //EditorBuildPackage.BuildIpa(); } //最后上传 UploadFormFileServer(platform); }
public void OnGUI_OneKeyExprot() { GUILayout.BeginVertical(); { GUILayout.Label("注:上面按钮操作,会默认生成到StreamingAssets", GUILayout.Width(500), GUILayout.Height(30)); isGenAndroidAssets = GUILayout.Toggle(isGenAndroidAssets, "生成Android资源(Windows公用)"); isGenIosAssets = GUILayout.Toggle(isGenIosAssets, "生成Ios资源"); // GUILayout.Label("导出地址:" + exportPath, GUILayout.Width(500)); // if (GUILayout.Button("一键导出[自动转hash]", GUILayout.Width(350), GUILayout.Height(30))) { //选择目录 exportPath = EditorUtility.OpenFolderPanel("选择导出目录", exportPath, ""); if (string.IsNullOrEmpty(exportPath)) { return; } //开始生成资源 { //生成android资源 if (isGenAndroidAssets) { var outPath = exportPath + "/" + BDUtils.GetPlatformPath(RuntimePlatform.Android); //1.编译脚本 try { ScriptBuildTools.BuildDll(Application.dataPath, outPath); EditorWindow_ScriptBuildDll.GenCLRBindingByAnalysis(); } catch (Exception e) { Debug.LogError(e.Message); return; } //2.打包资源 try { AssetBundleEditorTools.GenAssetBundle("Resource/Runtime/", outPath, BuildTarget.Android); } catch (Exception e) { Debug.LogError(e.Message); return; } //3.打包表格 try { Excel2SQLiteTools.GenSQLite(outPath); } catch (Exception e) { Debug.LogError(e.Message); return; } } //生成ios资源 if (isGenIosAssets) { var outPath = exportPath + "/" + BDUtils.GetPlatformPath(RuntimePlatform.IPhonePlayer); //1.编译脚本 try { ScriptBuildTools.BuildDll(Application.dataPath, outPath); EditorWindow_ScriptBuildDll.GenCLRBindingByAnalysis(); } catch (Exception e) { Debug.LogError(e.Message); return; } //2.打包资源 try { AssetBundleEditorTools.GenAssetBundle("Resource/Runtime/", outPath, BuildTarget.iOS); } catch (Exception e) { Debug.LogError(e.Message); return; } //3.打包表格 try { Excel2SQLiteTools.GenSQLite(outPath); } catch (Exception e) { Debug.LogError(e.Message); return; } } } EditorUtility.DisplayDialog("提示", "资源导出完成", "OK"); } // if (GUILayout.Button("上传到文件服务器[内网测试]", GUILayout.Width(350), GUILayout.Height(30))) { //先不实现,等待使用者实现 } if (GUILayout.Button("热更资源转hash[备用]", GUILayout.Width(350), GUILayout.Height(30))) { //选择目录 exportPath = EditorUtility.OpenFolderPanel("选择导出目录", exportPath, ""); if (string.IsNullOrEmpty(exportPath)) { return; } //自动转hash AssetUploadToServer.Assets2Hash(exportPath, ""); } } GUILayout.EndVertical(); }
public static void UnitTestILRuntimeWithRebuildDll() { EditorWindow_ScriptBuildDll.RoslynBuild(ScriptBuildTools.BuildMode.Debug); RunILRuntimeTest(); }
/// <summary> /// 构建dll /// </summary> public static void BuildDLL() { EditorWindow_ScriptBuildDll.RoslynBuild(outputPath, RuntimePlatform.Android, ScriptBuildTools.BuildMode.Release); }
/// <summary> /// 构建dll /// </summary> public static void BuildDLL() { //检查打包脚本 EditorWindow_ScriptBuildDll.RoslynBuild(CI_ASSETS_PATH, RuntimePlatform.Android, ScriptBuildTools.BuildMode.Release); }
public static void UnitTestILRuntimeWithRebuildDll() { EditorWindow_ScriptBuildDll.RoslynBuild(Application.streamingAssetsPath, BApplication.RuntimePlatform, ScriptBuildTools.BuildMode.Debug); RunILRuntimeTest(); }
static void Exprot() { var targetPath = "Assets/Code/BDFramework.Game/ILRuntime/Binding/Analysis"; //1.分析之前先删除,然后生成临时文件防止报错 // if (Directory.Exists(targetPath)) // { // Directory.Delete(targetPath, true); // } var fileContent = @" namespace ILRuntime.Runtime.Generated { class CLRBindings { internal static ILRuntime.Runtime.Enviorment.ValueTypeBinder<UnityEngine.Vector2> s_UnityEngine_Vector2_Binding_Binder = null; internal static ILRuntime.Runtime.Enviorment.ValueTypeBinder<UnityEngine.Vector3> s_UnityEngine_Vector3_Binding_Binder = null; internal static ILRuntime.Runtime.Enviorment.ValueTypeBinder<UnityEngine.Vector4> s_UnityEngine_Vector4_Binding_Binder = null; internal static ILRuntime.Runtime.Enviorment.ValueTypeBinder<UnityEngine.Quaternion> s_UnityEngine_Quaternion_Binding_Binder = null; public static void Initialize(ILRuntime.Runtime.Enviorment.AppDomain app) { } } } "; FileHelper.WriteAllText(targetPath + "/CLRBindings.cs", fileContent); AssetDatabase.Refresh(); var exporterDirectoryList = new string[] { "Assets/3rdPlugins/Dotween", // 第三方插件 "Assets/Code/BDFramework.Game", //Game "Assets/Code/Game/Demo", //Game demo "Assets/Scenes", //Scene BResources.MIX_SOURCE_FOLDER, //混淆源文件 "Assets/AssetGraph/BResourceAssetBundleConfig.asset", //SG "Assets/link.xml", }; var exportAssets = new List <string>(); foreach (var direct in exporterDirectoryList) { if (Directory.Exists(direct)) { var fs = Directory.GetFiles(direct, "*.*", SearchOption.AllDirectories); exportAssets.AddRange(fs); } else if (File.Exists(direct)) { exportAssets.Add(direct); } } var exportfs = exportAssets.Where((ex) => !ex.EndsWith(".meta")).ToArray(); //版本信息修改 #region version管理 //package 版本 var packageDataPath = AssetDatabase.GUIDToAssetPath("e56f3b41caab3304194319691ec2ebbb"); var bdLauncherCSPath = AssetDatabase.GUIDToAssetPath("53901f56d09f96d4886992ff20f43b1b"); var packageContent = File.ReadAllText(packageDataPath); var package = JsonMapper.ToObject <PackageData>(packageContent); //Editor Runtime版本 // var editorRuntimeVersionPath = AssetDatabase.GUIDToAssetPath("996622d6f14afc44dbd42c1cdfa8a362"); // var config = new BDFrameWorkConfig(); // config.Version = package.version; // File.WriteAllText(editorRuntimeVersionPath, JsonMapper.ToJson(config)); //Asset目录版本 var assetPathPath = AssetDatabase.GUIDToAssetPath("924d970067c935c4f8b818e6b4ab9e07"); File.WriteAllText(assetPathPath, package.version); AssetDatabase.Refresh(); //脚本 Editor string versioncode = @" public const string Version "; var filelines = File.ReadAllLines(bdLauncherCSPath); for (int i = 0; i < filelines.Length; i++) { var line = filelines[i]; if (line.Contains(versioncode)) { filelines[i] = string.Format("{0} = \"{1}\";", versioncode, package.version); // versioncode + " = " + package.version; break; } } File.WriteAllLines(bdLauncherCSPath, filelines); #endregion #region 场景配置 //让Release强制为persistent var bdlauncher = GameObject.Find("BDFrame").GetComponent <BDLauncher>(); bdlauncher.ConfigText = AssetDatabase.LoadAssetAtPath <TextAsset>(AssetDatabase.GUIDToAssetPath("517ff72e71a574546a91d76ad65770c9")); var config = GameObject.Find("BDFrame").GetComponent <Config>(); config.Data.CodeRoot = AssetLoadPathType.Persistent; config.Data.SQLRoot = AssetLoadPathType.Persistent; config.Data.ArtRoot = AssetLoadPathType.Persistent; AssetDatabase.SaveAssets(); //切换成Editor.json bdlauncher.ConfigText = AssetDatabase.LoadAssetAtPath <TextAsset>(AssetDatabase.GUIDToAssetPath("dac4b223fdff90143ac6a3d1980e120b")); config = GameObject.Find("BDFrame").GetComponent <Config>(); config.Data.CodeRoot = AssetLoadPathType.Editor; config.Data.SQLRoot = AssetLoadPathType.Editor; config.Data.ArtRoot = AssetLoadPathType.Editor; AssetDatabase.SaveAssets(); #endregion //最后,导出Asset.Package ExportPackageOptions op = ExportPackageOptions.Default; var packagePath = AssetDatabase.GUIDToAssetPath("69227cf6ea5304641ae95ffb93874014"); //AssetDatabase.ImportPackage(packagePath,true); AssetDatabase.ExportPackage(exportfs, packagePath, op); //重新生成clr分析文件 EditorWindow_ScriptBuildDll.GenCLRBindingByAnalysis(BApplication.RuntimePlatform); //debug EditorUtility.DisplayDialog("提示", "导出成功:\n" + packagePath, "ok"); }
/// <summary> /// 构建所有资源 /// </summary> /// <param name="platform">平台</param> /// <param name="outputPath">输出目录</param> /// <param name="setNewVersionNum">新版本号</param> static public void BuildAllAssets(RuntimePlatform platform, string outputPath, string setNewVersionNum = null) { var newVersionNum = ""; //触发事件 var lastPackageBuildInfo = GlobalAssetsHelper.GetPackageBuildInfo(outputPath, platform); var lastVersionNum = lastPackageBuildInfo.Version; //没有指定版本号,则需要触发版本号的实现逻辑 if (string.IsNullOrEmpty(setNewVersionNum)) { BDFrameworkPipelineHelper.OnBeginBuildAllAssets(platform, outputPath, lastVersionNum, out newVersionNum); } //项目没有实现提供新的版本号,则内部提供一个版本号 if (string.IsNullOrEmpty(newVersionNum) || lastVersionNum == newVersionNum) { //没指定版本号 if (string.IsNullOrEmpty(setNewVersionNum)) { newVersionNum = VersionNumHelper.AddVersionNum(lastVersionNum, add: 1); } //指定版本号 else { newVersionNum = VersionNumHelper.AddVersionNum(lastVersionNum, setNewVersionNum); } } //开始构建资源 var _outputPath = Path.Combine(outputPath, BApplication.GetPlatformPath(platform)); if (!Directory.Exists(_outputPath)) { Directory.CreateDirectory(_outputPath); } //1.编译脚本 try { EditorWindow_ScriptBuildDll.RoslynBuild(outputPath, platform, ScriptBuildTools.BuildMode.Release); } catch (Exception e) { Debug.LogError(e.Message); } //2.打包表格 try { Excel2SQLiteTools.AllExcel2SQLite(outputPath, platform); } catch (Exception e) { Debug.LogError(e.Message); } //3.打包资源 try { //var config = BDEditorApplication.BDFrameWorkFrameEditorSetting.BuildAssetBundle; AssetBundleEditorToolsV2.GenAssetBundle(outputPath, platform); } catch (Exception e) { Debug.LogError(e.Message); } //4.生成母包资源信息 GlobalAssetsHelper.GenBasePackageAssetBuildInfo(outputPath, platform, version: newVersionNum); //5.生成本地Assets.info配置 //这个必须最后生成!!!! //这个必须最后生成!!!! //这个必须最后生成!!!! var allServerAssetItemList = PublishPipelineTools.GetAssetItemList(outputPath, platform); var csv = CsvSerializer.SerializeToString(allServerAssetItemList); var assetsInfoPath = BResources.GetAssetsInfoPath(outputPath, platform); FileHelper.WriteAllText(assetsInfoPath, csv); // Debug.Log($"<color=yellow>{ BApplication.GetPlatformPath(platform)} - 旧版本:{lastPackageBuildInfo.Version} 新版本号:{newVersionNum} </color> "); //完成回调通知 BDFrameworkPipelineHelper.OnEndBuildAllAssets(platform, outputPath, newVersionNum); }