public override void OnInspectorGUI() { serializedObject.Update(); //draw the list using GUILayout, you can of course specify your own position and label list1.DoLayoutList(); serializedObject.ApplyModifiedProperties(); GUILayout.Space(5); JEngineSetting.MakeHorizontal(50, () => { if (GUILayout.Button("自动获取fields", GUILayout.Height(30))) { DoConvert(target as ClassBind); } }); GUILayout.Space(5); JEngineSetting.MakeHorizontal(50, () => { if (GUILayout.Button("自动更新fieldType", GUILayout.Height(30))) { DoFieldType(target as ClassBind); } }); GUILayout.Space(15); }
private void OnGUI() { //绘制标题 GUILayout.Space(10); GUI.skin.label.fontSize = 24; GUI.skin.label.alignment = TextAnchor.MiddleCenter; GUILayout.Label("ILRuntime适配器生成"); GUI.skin.label.fontSize = 18; GUILayout.Label("ILRuntime Adapter Generator"); //介绍 EditorGUILayout.HelpBox("本地工程类(没生成asmdef的),Assembly一栏不需要改,Class name一栏写类名(有命名空间带上);\n" + "有生成asmdef的工程类,Assembly一栏写asmdef里写的名字,Class name一栏写类名(有命名空间带上);\n" + "最后的Namespace是生成的适配器的命名空间,随便写,只要在适配器Helper引用激活即可\n\n" + "如果要生成Unity类的适配器,请确定找到了对应的module,并添加进热更工程,HotUpdateScripts/Dlls文件夹内,不然无法获取", MessageType.Info); //程序集 GUILayout.Space(50); JEngineSetting.MakeHorizontal(25, () => { EditorGUILayout.LabelField("Assembly 类的程序集"); }); JEngineSetting.MakeHorizontal(25, () => { _assembly = EditorGUILayout.TextField("", _assembly); }); //类名 GUILayout.Space(10); JEngineSetting.MakeHorizontal(25, () => { _class = EditorGUILayout.TextField("Class name 类名", _class); }); //命名空间 GUILayout.Space(10); JEngineSetting.MakeHorizontal(25, () => { EditorGUILayout.LabelField("Namespace for generated adapter 生成适配器的命名空间"); }); JEngineSetting.MakeHorizontal(25, () => { _namespace = EditorGUILayout.TextField("", _namespace); }); //生成 GUILayout.Space(10); JEngineSetting.MakeHorizontal(25, () => { if (GUILayout.Button("Generate 生成")) { GenAdapter(); } }); }
static void Update() { if (!isDone || EditorApplication.isPlaying) { return; } if (!Directory.Exists("Assets/HotUpdateResources/Dll/Hidden~")) //DLL导入到隐藏文件夹,防止每次加载浪费时间 { Directory.CreateDirectory("Assets/HotUpdateResources/Dll/Hidden~"); } if (!File.Exists(DLLMgr.DllPath)) //没热更dll就返回 { return; } //有的话比较日期 DateTime lastModified = File.GetLastWriteTime(DLLMgr.DllPath); string lastModifiedStr = lastModified.ToString(JEngineSetting.GetString(JEngineSetting.DATE_FORMAT)); if (JEngineSetting.LastDLLCleanUpTime != lastModifiedStr) //不一样再处理 { var files = di.GetFiles(); var watch = new Stopwatch(); int counts = 0; List <string> fileNames = Directory.GetFiles("Assets/", "*.dll", SearchOption.AllDirectories).ToList(); DLLMgr.Delete("Assets/HotUpdateResources/Dll/HotUpdateScripts.bytes"); watch = new Stopwatch(); DLLMgr.MakeBytes(); watch.Stop(); if (watch.ElapsedMilliseconds > 0) { Log.Print("Convert DLL in: " + watch.ElapsedMilliseconds + " ms."); } AssetDatabase.Refresh(); JEngineSetting.LastDLLCleanUpTime = lastModifiedStr; isDone = false; fileNames = fileNames.FindAll((x) => !x.Contains("~")); watch.Start(); foreach (var file in files) { var name = file.Name; if (!File.Exists(library.FullName + "/" + name) && !name.Contains("netstandard") && !name.Contains("HotUpdateScripts") && !name.Contains("Unity") && !name.Contains("System") && ((name.Contains(".pdb") || name.Contains(".dll")))) { if (fileNames.Find(x => x.Contains(name)) == null) //不存在就添加 { DLLMgr.Delete(file.FullName.Replace("Hidden~", "../Dll")); File.Move(file.FullName, file.FullName.Replace("Hidden~", "../Dll")); Log.Print( $"Find new referenced dll `{name}`, note that your hot update code may not be able " + $"to run without rebuild application\n" + $"发现新的引用DLL`{name}`,请注意,游戏可能需要重新打包,否则热更代码无法将有可能运行"); } else //存在就删了 { DLLMgr.Delete(file.FullName); counts++; } } else if (!name.Contains("HotUpdateScripts")) { DLLMgr.Delete(file.FullName); counts++; } else { if (!name.Contains("HotUpdateScripts")) { Log.PrintError($"无法删除{file.FullName},请手动删除"); } } } watch.Stop(); if (counts > 0) //如果删除过东西,就代表DLL更新了,就需要生成文件 { Log.Print("Cleaned: " + counts + " files in: " + watch.ElapsedMilliseconds + " ms."); } isDone = true; } if (!File.Exists("Assets/HotUpdateResources/Dll/HotUpdateScripts.bytes")) { isDone = false; var watch = new Stopwatch(); DLLMgr.MakeBytes(); watch.Stop(); Log.Print("Convert DLL in: " + watch.ElapsedMilliseconds + " ms."); AssetDatabase.Refresh(); isDone = true; } }