GameWindow.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using BansheeEngine;
  2. namespace BansheeEditor
  3. {
  4. /// <summary>
  5. /// Displays in-game viewport in the editor.
  6. /// </summary>
  7. public class GameWindow : EditorWindow
  8. {
  9. /// <summary>
  10. /// Opens the game window.
  11. /// </summary>
  12. [MenuItem("Windows/Game", ButtonModifier.CtrlAlt, ButtonCode.G, 6000)]
  13. private static void OpenGameWindow()
  14. {
  15. OpenWindow<GameWindow>();
  16. }
  17. /// <summary>
  18. /// Starts execution of the game in the game window.
  19. /// </summary>
  20. [MenuItem("Tools/Play", 9300)]
  21. [ToolbarItem("Play", ToolbarIcon.Play, "", 1800, true)]
  22. private static void Play()
  23. {
  24. if (EditorApplication.IsPaused)
  25. EditorApplication.IsPaused = false;
  26. else
  27. EditorApplication.IsPlaying = !EditorApplication.IsPlaying;
  28. }
  29. /// <summary>
  30. /// Pauses the execution of the game on the current frame.
  31. /// </summary>
  32. [MenuItem("Tools/Pause", 9299)]
  33. [ToolbarItem("Pause", ToolbarIcon.Pause, "", 1799)]
  34. private static void Pause()
  35. {
  36. EditorApplication.IsPaused = !EditorApplication.IsPaused;
  37. }
  38. /// <summary>
  39. /// Moves the execution of the game by one frame forward.
  40. /// </summary>
  41. [MenuItem("Tools/Step", 9298)]
  42. [ToolbarItem("Step", ToolbarIcon.Step, "", 1798)]
  43. private static void Step()
  44. {
  45. EditorApplication.FrameStep();
  46. }
  47. /// <inheritdoc/>
  48. protected override LocString GetDisplayName()
  49. {
  50. return new LocEdString("Game");
  51. }
  52. }
  53. }