DebugWindow.cs 2.4 KB

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