AssemblyEditor.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System.IO;
  2. using UnityEditor;
  3. using UnityEngine;
  4. namespace ET
  5. {
  6. public static class AssemblyEditor
  7. {
  8. private static readonly string[] DllNames = { "ET.Hotfix", "ET.HotfixView", "ET.Model", "ET.ModelView" };
  9. [InitializeOnLoadMethod]
  10. static void Initialize()
  11. {
  12. EditorApplication.playModeStateChanged += change =>
  13. {
  14. switch (change)
  15. {
  16. case PlayModeStateChange.ExitingEditMode:
  17. {
  18. OnExitingEditMode();
  19. break;
  20. }
  21. }
  22. };
  23. }
  24. /// <summary>
  25. /// 退出编辑模式时处理(即将进入运行模式)
  26. /// EnableDll模式时, 屏蔽掉Library的dll(通过改文件后缀方式屏蔽), 仅使用Define.CodeDir下的dll
  27. /// </summary>
  28. static void OnExitingEditMode()
  29. {
  30. foreach (string dll in DllNames)
  31. {
  32. string dllFile = $"{Application.dataPath}/../Library/ScriptAssemblies/{dll}.dll";
  33. if (File.Exists(dllFile))
  34. {
  35. File.Delete(dllFile);
  36. }
  37. string pdbFile = $"{Application.dataPath}/../Library/ScriptAssemblies/{dll}.pdb";
  38. if (File.Exists(pdbFile))
  39. {
  40. File.Delete(pdbFile);
  41. }
  42. }
  43. }
  44. }
  45. }