/// <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); } }
/// <summary> /// 编译模式 /// </summary> /// <param name="mode"></param> static void RoslynBuild(ScriptBuildTools.BuildMode mode) { //1.build dll var outpath_win = Application.streamingAssetsPath + "/" + BDUtils.GetPlatformPath(Application.platform); ScriptBuildTools.BuildDll(Application.dataPath, outpath_win, mode); //2.同步到其他两个目录 var outpath_android = Application.streamingAssetsPath + "/" + BDUtils.GetPlatformPath(RuntimePlatform.Android) + "/hotfix/hotfix.dll"; var outpath_ios = Application.streamingAssetsPath + "/" + BDUtils.GetPlatformPath(RuntimePlatform.IPhonePlayer) + "/hotfix/hotfix.dll"; var source = outpath_win + "/hotfix/hotfix.dll"; var bytes = File.ReadAllBytes(source); if (source != outpath_android) { FileHelper.WriteAllBytes(outpath_android, bytes); } if (source != outpath_ios) { FileHelper.WriteAllBytes(outpath_ios, bytes); } //3.生成CLRBinding GenCLRBindingByAnalysis(); AssetDatabase.Refresh(); Debug.Log("脚本打包完毕"); }
public void OnGUI() { GUILayout.BeginVertical(); { GUILayout.Label("1.脚本打包", EditorGUIHelper.TitleStyle); GUILayout.Space(5); //第二排 GUILayout.BeginHorizontal(); { // if (GUILayout.Button("1.编译dll (.net版)", GUILayout.Width(200), GUILayout.Height(30))) { ScriptBuildTools.BuildDll(Application.dataPath, Application.streamingAssetsPath + "/" + BDUtils.GetPlatformPath(Application.platform), ScriptBuildTools.BuildMode.DotNet); AssetDatabase.Refresh(); } if (GUILayout.Button("[mono版]", GUILayout.Width(100), GUILayout.Height(30))) { //1.build dll var outpath_win = Application.streamingAssetsPath + "/" + BDUtils.GetPlatformPath(Application.platform); ScriptBuildTools.BuildDll(Application.dataPath, outpath_win); //3.生成CLRBinding GenCLRBindingByAnalysis(); AssetDatabase.Refresh(); Debug.Log("脚本打包完毕"); } } GUILayout.EndHorizontal(); if (GUILayout.Button("2.生成CLRBinding · one for all[已集成]", GUILayout.Width(305), GUILayout.Height(30))) { GenCLRBindingByAnalysis(); } if (GUILayout.Button("3.生成跨域Adapter[没事别瞎点]", GUILayout.Width(305), GUILayout.Height(30))) { GenCrossBindAdapter(); } if (GUILayout.Button("4.生成Link.xml", GUILayout.Width(305), GUILayout.Height(30))) { StripCode.GenLinkXml(); } GUI.color = Color.green; GUILayout.Label( @"注意事项: 1.编译服务使用codedom,请放心使用 2.如编译出现报错,请仔细看报错信息,和报错的代码行列, 一般均为语法错 3.语法报错原因可能有:主工程访问hotfix中的类, 使用宏 编译时代码结构发生变化..等等,需要细心的你去发现" ); GUI.color = GUI.backgroundColor; } GUILayout.EndVertical(); }
/// <summary> /// 编译模式 /// </summary> /// <param name="mode"></param> static public void RoslynBuild(ScriptBuildTools.BuildMode mode, string outpath = null) { var targetPath = "Assets/Code/Game/ILRuntime/Binding/Analysis"; //分析之前先删除,然后生成临时文件防止报错 if (Directory.Exists(targetPath)) { Directory.Delete(targetPath, true); } var fileContent = @" namespace ILRuntime.Runtime.Generated { class CLRBindings { public static void Initialize(ILRuntime.Runtime.Enviorment.AppDomain app) { } } } "; FileHelper.WriteAllText(targetPath + "/CLRBindings.cs", fileContent); AssetDatabase.Refresh(); //这里必须要刷新 //没指定,走默认模式 if (string.IsNullOrEmpty(outpath)) { //1.build dll var outpath_win = Application.streamingAssetsPath + "/" + BApplication.GetPlatformPath(Application.platform); ScriptBuildTools.BuildDll(outpath_win, mode); //2.同步到其他两个目录 var outpath_android = Application.streamingAssetsPath + "/" + BApplication.GetPlatformPath(RuntimePlatform.Android) + DLLPATH; var outpath_ios = Application.streamingAssetsPath + "/" + BApplication.GetPlatformPath(RuntimePlatform.IPhonePlayer) + DLLPATH; var source = outpath_win + DLLPATH; var bytes = File.ReadAllBytes(source); if (source != outpath_android) { FileHelper.WriteAllBytes(outpath_android, bytes); } if (source != outpath_ios) { FileHelper.WriteAllBytes(outpath_ios, bytes); } } else { //指定了直接 build ScriptBuildTools.BuildDll(outpath, mode); } //3.预绑定 GenPreCLRBinding(); //4.生成AnalysisCLRBinding GenCLRBindingByAnalysis(); AssetDatabase.Refresh(); Debug.Log("脚本打包完毕"); }
/// <summary> /// 编译模式 /// </summary> /// <param name="mode"></param> static public void RoslynBuild(ScriptBuildTools.BuildMode mode, string outpath = null) { var targetPath = "Assets/Code/Game/ILRuntime/Binding/Analysis"; //1.分析之前先删除,然后生成临时文件防止报错 if (Directory.Exists(targetPath)) { Directory.Delete(targetPath, true); } var fileContent = @" namespace ILRuntime.Runtime.Generated { class CLRBindings { public static void Initialize(ILRuntime.Runtime.Enviorment.AppDomain app) { } } } "; FileHelper.WriteAllText(targetPath + "/CLRBindings.cs", fileContent); AssetDatabase.Refresh(); //这里必须要刷新 //2.生成DLL if (string.IsNullOrEmpty(outpath)) { //1.build dll var outpath_win = Application.streamingAssetsPath + "/" + BApplication.GetPlatformPath(Application.platform); ScriptBuildTools.BuildDll(outpath_win, mode); } else { //指定了直接 build ScriptBuildTools.BuildDll(outpath, mode); } //3.预绑定 //GenPreCLRBinding(); //4.生成自动分析绑定 GenCLRBindingByAnalysis(); AssetDatabase.Refresh(); Debug.Log("脚本打包完毕"); }
/// <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="outpath"></param> /// <param name="platform"></param> /// <param name="mode"></param> static public void RoslynBuild(string outpath, RuntimePlatform platform, ScriptBuildTools.BuildMode mode, bool isShowTips = true) { //触发bd环境周期 BDFrameworkPipelineHelper.OnBeginBuildHotfixDLL(); 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(); //这里必须要刷新 //2.生成DLL ScriptBuildTools.BuildDll(outpath, platform, mode, isShowTips); //3.预绑定 //GenPreCLRBinding(); //4.生成自动分析绑定 GenCLRBindingByAnalysis(platform, outpath); //5.拷贝 CopyDLLToOther(outpath, platform); AssetDatabase.Refresh(); //触发bd环境周期 BDFrameworkPipelineHelper.OnEndBuildDLL(outpath); }
/// <summary> /// 编译模式 /// </summary> /// <param name="outpath"></param> /// <param name="platform"></param> /// <param name="mode"></param> static public void RoslynBuild(string outpath, RuntimePlatform platform, ScriptBuildTools.BuildMode mode) { //触发bd环境周期 BDFrameEditorBehaviorHelper.OnBeginBuildDLL(); var targetPath = "Assets/Code/Game/ILRuntime/Binding/Analysis"; //1.分析之前先删除,然后生成临时文件防止报错 if (Directory.Exists(targetPath)) { Directory.Delete(targetPath, true); } var fileContent = @" namespace ILRuntime.Runtime.Generated { class CLRBindings { public static void Initialize(ILRuntime.Runtime.Enviorment.AppDomain app) { } } } "; FileHelper.WriteAllText(targetPath + "/CLRBindings.cs", fileContent); AssetDatabase.Refresh(); //这里必须要刷新 //2.生成DLL ScriptBuildTools.BuildDll(outpath, platform, mode); //3.预绑定 //GenPreCLRBinding(); //4.生成自动分析绑定 GenCLRBindingByAnalysis(platform, outpath); AssetDatabase.Refresh(); //触发bd环境周期 BDFrameEditorBehaviorHelper.OnEndBuildDLL(outpath); AssetHelper.GenPackageBuildInfo(outpath, platform); Debug.Log("脚本打包完毕"); }
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 void Init(IQFrameworkContainer container) { SerializeHelper.SerializeContainer.RegisterInstance <IJsonSerializer>(new JsonDotnetSerializer()); mRootLayout = new VerticalLayout(); EasyIMGUI.Label().Text("ScriptKitILRuntime 的编辑器").FontSize(12).Parent(mRootLayout); //EditorStyles.popup.fixedHeight = 30; var verticalLayout = new VerticalLayout("box").Parent(mRootLayout); var versionText = "0"; verticalLayout.AddChild(new HorizontalLayout() .AddChild(EasyIMGUI.Label().Text("版本号(数字):")) .AddChild(EasyIMGUI.TextField() .Text(versionText) .Self(text => text.Content.Bind(t => versionText = t))) ); var versionBtn = EasyIMGUI.Button(); versionBtn.AddLayoutOption(GUILayout.Height(30)); verticalLayout.AddChild(versionBtn.Text("生成版本信息").OnClick(() => { var generatePath = Application.streamingAssetsPath + "/AssetBundles/" + AssetBundleSettings.GetPlatformForAssetBundles(Application.platform) + "/"; var filenames = Directory.GetFiles(generatePath); new DLLVersion() { Assets = filenames.Select(f => f.GetFileName()).ToList(), Version = versionText.ToInt() }.SaveJson(generatePath + "/hotfix.json"); AssetDatabase.Refresh(); })); EasyIMGUI.Custom().OnGUI(() => { GUILayout.BeginVertical(); { showGenDll = EditorGUILayout.BeginFoldoutHeaderGroup(showGenDll, "编译热更dll"); if (showGenDll) { GUILayout.BeginHorizontal(); if (GUILayout.Button("编译dll(Debug)", GUILayout.Height(30))) { var outpath_win = Application.streamingAssetsPath + "/AssetBundles/" + AssetBundleSettings.GetPlatformForAssetBundles(Application.platform); ScriptBuildTools.BuildDll(outpath_win, ScriptBuildTools.BuildMode.Debug); } if (GUILayout.Button("编译dll(Release)", GUILayout.Height(30))) { var outpath_win = Application.streamingAssetsPath + "/AssetBundles/" + AssetBundleSettings.GetPlatformForAssetBundles(Application.platform); ScriptBuildTools.BuildDll(outpath_win, ScriptBuildTools.BuildMode.Release); } GUILayout.EndHorizontal(); GUI.color = Color.green; GUILayout.Label( @"注意事项: 1.编译服务使用Roslyn,请放心使用 2.如编译出现报错,请仔细看报错信息,和报错的代码行列, 一般均为语法错 3.语法报错原因可能有:主工程访问hotfix中的类, 使用宏 编译时代码结构发生变化..等等,需要细心的你去发现" ); GUI.color = GUI.backgroundColor; } EditorGUILayout.EndFoldoutHeaderGroup(); showGenAdapter = EditorGUILayout.BeginFoldoutHeaderGroup(showGenAdapter, "生成跨域Adapter"); if (showGenAdapter) { GUILayout.BeginHorizontal(); GUILayout.Label("程序集名:"); assemblyName = GUILayout.TextField(assemblyName); GUILayout.EndHorizontal(); EditorGUILayout.HelpBox("类名如果有命名空间需要带上", MessageType.Info); GUILayout.BeginHorizontal(); GUILayout.Label("类名:"); adapterClassName = GUILayout.TextField(adapterClassName); GUILayout.EndHorizontal(); if (GUILayout.Button("生成", GUILayout.Height(30))) { GenCrossBindAdapter(); } } EditorGUILayout.EndFoldoutHeaderGroup(); showGenDllBind = EditorGUILayout.BeginFoldoutHeaderGroup(showGenDllBind, "Clr Binding And Link"); if (showGenDllBind) { GUILayout.BeginHorizontal(); if (GUILayout.Button("生成Clr绑定(不知道干嘛别点!)", GUILayout.Height(30))) { GenClrBindingByAnalysis(); } if (GUILayout.Button("生成Link.xml", GUILayout.Height(30))) { StripCode.GenLinkXml(); } GUILayout.EndHorizontal(); } EditorGUILayout.EndFoldoutHeaderGroup(); } GUILayout.EndVertical(); }).Parent(verticalLayout); var runModelPop = new EnumPopupView(ILRuntimeScriptSetting.Default.HotfixRunMode); runModelPop.Style.Value.fixedHeight = 30; runModelPop.AddLayoutOption(GUILayout.Height(30)); runModelPop.ValueProperty.Bind(v => ILRuntimeScriptSetting.Default.HotfixRunMode = (HotfixCodeRunMode)v); EasyIMGUI.Horizontal().AddChild(EasyIMGUI.Label().Text("运行模式")).AddChild(runModelPop).Parent(mRootLayout); }