DebugWindow.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. GUILayout horzLayout = GUI.AddLayoutX();
  23. horzLayout.AddElement(refreshAssembly);
  24. horzLayout.AddElement(compileGame);
  25. horzLayout.AddElement(openColorPicker);
  26. GUIButton testExplicitBtn = new GUIButton("TESTING EXPLICIT");
  27. testExplicitBtn.Bounds = compileGame.Bounds;
  28. GUIPanel overlay = GUI.AddPanel(-1);
  29. overlay.SetWidth(Width);
  30. overlay.SetHeight(Height);
  31. overlay.AddElement(testExplicitBtn);
  32. }
  33. [MenuItem("Window/Test", ButtonModifier.ShiftAlt, ButtonCode.A)]
  34. private static void TestMenuItem()
  35. {
  36. ColorPicker.Show();
  37. }
  38. void RefreshAssembly_OnClick()
  39. {
  40. Internal_RefreshAssembly();
  41. }
  42. void CompileGame_OnClick()
  43. {
  44. CompilerInstance ci = ScriptCompiler.CompileAsync(ScriptAssemblyType.Game, PlatformType.Windows, true, "D:\\AssemblyOutput");
  45. while (!ci.IsDone)
  46. {
  47. Debug.Log("Compiling...");
  48. Thread.Sleep(50);
  49. }
  50. Debug.Log("COMPILATION DONE!");
  51. for(int i = 0; i < ci.ErrorMessages.Length; i++)
  52. Debug.Log("ERROR: " + ci.ErrorMessages[i].file + ": " + ci.ErrorMessages[i].line + " - " + ci.ErrorMessages[i].message);
  53. for (int i = 0; i < ci.WarningMessages.Length; i++)
  54. Debug.Log("WARNING: " + ci.WarningMessages[i].file + ": " + ci.WarningMessages[i].line + " - " + ci.WarningMessages[i].message);
  55. }
  56. void OpenColorPicker()
  57. {
  58. ColorPicker.Show();
  59. debugSlowDown = true;
  60. }
  61. void OnEditorUpdate()
  62. {
  63. //if (debugSlowDown)
  64. // Thread.Sleep(5000);
  65. }
  66. [MethodImpl(MethodImplOptions.InternalCall)]
  67. internal static extern void Internal_RefreshAssembly();
  68. }
  69. }