DebugWindow.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. private void OnInitialize()
  14. {
  15. GUIButton refreshAssembly = new GUIButton("Refresh assembly");
  16. refreshAssembly.OnClick += RefreshAssembly_OnClick;
  17. GUIButton compileGame = new GUIButton("Compile game assembly");
  18. compileGame.OnClick += CompileGame_OnClick;
  19. GUI.layout.AddElement(refreshAssembly);
  20. GUI.layout.AddElement(compileGame);
  21. GUIButton testExplicitBtn = new GUIButton("TESTING EXPLICIT");
  22. testExplicitBtn.Bounds = compileGame.Bounds;
  23. GUIArea overlay = GUI.AddArea(0, 0, Width, Height, -1, GUILayoutType.Explicit);
  24. overlay.layout.AddElement(testExplicitBtn);
  25. }
  26. [MenuItem("Window/Test", ButtonModifier.ShiftAlt, ButtonCode.A)]
  27. private static void TestMenuItem()
  28. {
  29. ColorPicker.Show();
  30. }
  31. void RefreshAssembly_OnClick()
  32. {
  33. Internal_RefreshAssembly();
  34. }
  35. void CompileGame_OnClick()
  36. {
  37. CompilerInstance ci = ScriptCompiler.CompileAsync(ScriptAssemblyType.Game, PlatformType.Windows, true, "D:\\AssemblyOutput");
  38. while (!ci.IsDone)
  39. {
  40. Debug.Log("Compiling...");
  41. Thread.Sleep(50);
  42. }
  43. Debug.Log("COMPILATION DONE!");
  44. for(int i = 0; i < ci.ErrorMessages.Length; i++)
  45. Debug.Log("ERROR: " + ci.ErrorMessages[i].file + ": " + ci.ErrorMessages[i].line + " - " + ci.ErrorMessages[i].message);
  46. for (int i = 0; i < ci.WarningMessages.Length; i++)
  47. Debug.Log("WARNING: " + ci.WarningMessages[i].file + ": " + ci.WarningMessages[i].line + " - " + ci.WarningMessages[i].message);
  48. }
  49. [MethodImpl(MethodImplOptions.InternalCall)]
  50. internal static extern void Internal_RefreshAssembly();
  51. }
  52. }