DebugWindow.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. }
  22. void RefreshAssembly_OnClick()
  23. {
  24. Internal_RefreshAssembly();
  25. }
  26. void CompileGame_OnClick()
  27. {
  28. CompilerInstance ci = ScriptCompiler.CompileAsync(ScriptAssemblyType.Game, PlatformType.Windows, true, "D:\\AssemblyOutput");
  29. while (!ci.IsDone)
  30. {
  31. Debug.Log("Compiling...");
  32. Thread.Sleep(50);
  33. }
  34. Debug.Log("COMPILATION DONE!");
  35. for(int i = 0; i < ci.ErrorMessages.Length; i++)
  36. Debug.Log("ERROR: " + ci.ErrorMessages[i].file + ": " + ci.ErrorMessages[i].line + " - " + ci.ErrorMessages[i].message);
  37. for (int i = 0; i < ci.WarningMessages.Length; i++)
  38. Debug.Log("WARNING: " + ci.WarningMessages[i].file + ": " + ci.WarningMessages[i].line + " - " + ci.WarningMessages[i].message);
  39. }
  40. [MethodImpl(MethodImplOptions.InternalCall)]
  41. internal static extern void Internal_RefreshAssembly();
  42. }
  43. }