BuildHotfixEditor.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System.IO;
  2. using UnityEditor;
  3. using UnityEngine;
  4. using GFGGame;
  5. namespace GFGEditor
  6. {
  7. [InitializeOnLoad]
  8. public class BuildHotfixEditor
  9. {
  10. //Unity代码生成dll位置
  11. private const string ScriptAssembliesDir = "Library/ScriptAssemblies";
  12. //热更代码dll文件
  13. private const string HotfixDll = "Game.HotUpdate.dll";
  14. //热更代码pdb文件
  15. private const string HotfixPdb = "Game.HotUpdate.pdb";
  16. //热更代码存放位置
  17. private const string CodeDir = LauncherConfig.DllDirHotfix;
  18. //热更代码存放位置
  19. private const string EditorDllDir = "Assets/Editor/Excel/DLL/";
  20. static BuildHotfixEditor()
  21. {
  22. CopyCode();
  23. }
  24. static void CopyCode()
  25. {
  26. Debug.Log($"Copy Hotfix Code");
  27. if (!Directory.Exists(CodeDir))
  28. Directory.CreateDirectory(CodeDir);
  29. var path = Path.Combine(ScriptAssembliesDir, HotfixDll);
  30. if (File.Exists(path))
  31. {
  32. File.Copy(path, Path.Combine(CodeDir, "Game.HotUpdate.dll.bytes"), true);
  33. //File.Delete(path);
  34. path = Path.Combine(ScriptAssembliesDir, HotfixPdb);
  35. File.Copy(path, Path.Combine(CodeDir, "Game.HotUpdate.pdb.bytes"), true);
  36. //File.Delete(path);
  37. Debug.Log($"复制Game.HotUpdate.dll, Game.HotUpdate.pdb到Res/Code完成");
  38. AssetDatabase.Refresh();
  39. }
  40. }
  41. }
  42. }