DebugWindow.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.CompilerServices;
  5. using System.Text;
  6. using System.Threading;
  7. using System.Threading.Tasks;
  8. using BansheeEngine;
  9. namespace BansheeEditor
  10. {
  11. internal class DebugWindow : EditorWindow
  12. {
  13. bool debugSlowDown = false;
  14. private void OnInitialize()
  15. {
  16. GUIButton refreshAssembly = new GUIButton("Refresh assembly");
  17. refreshAssembly.OnClick += RefreshAssembly_OnClick;
  18. GUIButton compileGame = new GUIButton("Compile game assembly");
  19. compileGame.OnClick += CompileGame_OnClick;
  20. GUIButton openColorPicker = new GUIButton("Color picker");
  21. openColorPicker.OnClick += OpenColorPicker;
  22. GUI.layout.AddElement(refreshAssembly);
  23. GUI.layout.AddElement(compileGame);
  24. GUI.layout.AddElement(openColorPicker);
  25. GUIButton testExplicitBtn = new GUIButton("TESTING EXPLICIT");
  26. testExplicitBtn.Bounds = compileGame.Bounds;
  27. GUIArea overlay = GUI.AddArea(0, 0, Width, Height, -1, GUILayoutType.Explicit);
  28. overlay.layout.AddElement(testExplicitBtn);
  29. }
  30. [MenuItem("Window/Test", ButtonModifier.ShiftAlt, ButtonCode.A)]
  31. private static void TestMenuItem()
  32. {
  33. ColorPicker.Show();
  34. }
  35. void RefreshAssembly_OnClick()
  36. {
  37. Internal_RefreshAssembly();
  38. }
  39. void CompileGame_OnClick()
  40. {
  41. CompilerInstance ci = ScriptCompiler.CompileAsync(ScriptAssemblyType.Game, PlatformType.Windows, true, "D:\\AssemblyOutput");
  42. while (!ci.IsDone)
  43. {
  44. Debug.Log("Compiling...");
  45. Thread.Sleep(50);
  46. }
  47. Debug.Log("COMPILATION DONE!");
  48. for(int i = 0; i < ci.ErrorMessages.Length; i++)
  49. Debug.Log("ERROR: " + ci.ErrorMessages[i].file + ": " + ci.ErrorMessages[i].line + " - " + ci.ErrorMessages[i].message);
  50. for (int i = 0; i < ci.WarningMessages.Length; i++)
  51. Debug.Log("WARNING: " + ci.WarningMessages[i].file + ": " + ci.WarningMessages[i].line + " - " + ci.WarningMessages[i].message);
  52. }
  53. void OpenColorPicker()
  54. {
  55. ColorPicker.Show();
  56. debugSlowDown = true;
  57. }
  58. void EditorUpdate()
  59. {
  60. //if (debugSlowDown)
  61. // Thread.Sleep(5000);
  62. }
  63. [MethodImpl(MethodImplOptions.InternalCall)]
  64. internal static extern void Internal_RefreshAssembly();
  65. }
  66. }