CompileDllsToolbar.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using ToolbarExtension;
  2. using UnityEditor;
  3. using UnityEngine;
  4. namespace ET
  5. {
  6. public class CompileDllToolbar
  7. {
  8. private static readonly GUIContent reloadButtonGUIContent = new GUIContent("Reload", "Compile And Reload ET.Hotfix Dll When Playing.");
  9. private static readonly GUIContent compileButtonGUIContent = new GUIContent("Compile", "Compile All ET Dll.");
  10. [Toolbar(OnGUISide.Left, 0)]
  11. static void OnToolbarGUI()
  12. {
  13. EditorGUI.BeginDisabledGroup(!Application.isPlaying);
  14. {
  15. if (GUILayout.Button(reloadButtonGUIContent))
  16. {
  17. GlobalConfig globalConfig = Resources.Load<GlobalConfig>("GlobalConfig");
  18. if (!globalConfig.EnableDll)
  19. {
  20. Debug.LogError("Plaese reload after open EnableDll!");
  21. return;
  22. }
  23. AssemblyTool.DoCompile();
  24. CodeLoader.Instance.Reload();
  25. Debug.Log("reload success!");
  26. }
  27. }
  28. EditorGUI.EndDisabledGroup();
  29. if (GUILayout.Button(compileButtonGUIContent))
  30. {
  31. AssemblyTool.DoCompile();
  32. Debug.Log("compile success!");
  33. }
  34. }
  35. }
  36. }