DebugWindow.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. void RefreshAssembly_OnClick()
  34. {
  35. Internal_RefreshAssembly();
  36. }
  37. void CompileGame_OnClick()
  38. {
  39. CompilerInstance ci = ScriptCompiler.CompileAsync(ScriptAssemblyType.Game, PlatformType.Windows, true, "D:\\AssemblyOutput");
  40. while (!ci.IsDone)
  41. {
  42. Debug.Log("Compiling...");
  43. Thread.Sleep(50);
  44. }
  45. Debug.Log("COMPILATION DONE!");
  46. for(int i = 0; i < ci.ErrorMessages.Length; i++)
  47. Debug.Log("ERROR: " + ci.ErrorMessages[i].file + ": " + ci.ErrorMessages[i].line + " - " + ci.ErrorMessages[i].message);
  48. for (int i = 0; i < ci.WarningMessages.Length; i++)
  49. Debug.Log("WARNING: " + ci.WarningMessages[i].file + ": " + ci.WarningMessages[i].line + " - " + ci.WarningMessages[i].message);
  50. }
  51. void OpenColorPicker()
  52. {
  53. ColorPicker.Show();
  54. debugSlowDown = true;
  55. }
  56. void OnEditorUpdate()
  57. {
  58. //if (debugSlowDown)
  59. // Thread.Sleep(5000);
  60. }
  61. [MethodImpl(MethodImplOptions.InternalCall)]
  62. internal static extern void Internal_RefreshAssembly();
  63. }
  64. }