MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / GameWindow

Method GameWindow

Source/Editor/Windows/GameWindow.cs:388–493  ·  view source on GitHub ↗

Initializes a new instance of the class. The editor.

(Editor editor)

Source from the content-addressed store, hash-verified

386 /// </summary>
387 /// <param name="editor">The editor.</param>
388 public GameWindow(Editor editor)
389 : base(editor, true, ScrollBars.None)
390 {
391 Title = "Game";
392 Icon = editor.Icons.Play64;
393 AutoFocus = true;
394
395 var task = MainRenderTask.Instance;
396
397 // Setup viewport
398 _viewport = new ScaledRenderOutputControl(task)
399 {
400 AnchorPreset = AnchorPresets.StretchAll,
401 Offsets = Margin.Zero,
402 AutoFocus = false,
403 Parent = this
404 };
405 task.PostRender += OnPostRender;
406
407 // Override the game GUI root
408 _guiRoot = new GameRoot
409 {
410 Parent = _viewport
411 };
412 RootControl.GameRoot = _guiRoot.UIRoot;
413
414 SizeChanged += control => { ResizeViewport(); };
415
416 Editor.StateMachine.PlayingState.SceneDuplicating += PlayingStateOnSceneDuplicating;
417 Editor.StateMachine.PlayingState.SceneRestored += PlayingStateOnSceneRestored;
418
419 // Link editor options
420 Editor.Options.OptionsChanged += OnOptionsChanged;
421 OnOptionsChanged(Editor.Options.Options);
422
423 InputActions.Add(options => options.TakeScreenshot, () => Screenshot.Capture(string.Empty));
424 InputActions.Add(options => options.DebuggerUnlockMouse, UnlockMouseInPlay);
425 InputActions.Add(options => options.ToggleFullscreen, () => { if (Editor.IsPlayMode) IsMaximized = !IsMaximized; });
426 InputActions.Add(options => options.Play, Editor.Instance.Simulation.DelegatePlayOrStopPlayInEditor);
427 InputActions.Add(options => options.Pause, Editor.Instance.Simulation.RequestResumeOrPause);
428 InputActions.Add(options => options.StepFrame, Editor.Instance.Simulation.RequestPlayOneFrame);
429#if USE_PROFILER
430 InputActions.Add(options => options.ProfilerStartStop, () =>
431 {
432 bool recording = !Editor.Instance.Windows.ProfilerWin.LiveRecording;
433 Editor.Instance.Windows.ProfilerWin.LiveRecording = recording;
434 Editor.Instance.UI.AddStatusMessage($"Profiling {(recording ? "started" : "stopped")}.");
435 });
436 InputActions.Add(options => options.ProfilerClear, () =>
437 {
438 Editor.Instance.Windows.ProfilerWin.Clear();
439 Editor.Instance.UI.AddStatusMessage("Profiling results cleared.");
440 });
441#endif
442 InputActions.Add(options => options.Save, () =>
443 {
444 if (Editor.IsPlayMode)
445 return;

Callers

nothing calls this directly

Calls 14

FocusFunction · 0.85
CaptureMethod · 0.80
AddStatusMessageMethod · 0.80
SaveAllMethod · 0.80
FocusCommandMethod · 0.80
AddMethod · 0.45
ClearMethod · 0.45
PerformUndoMethod · 0.45
PerformRedoMethod · 0.45
CutMethod · 0.45
CopyMethod · 0.45
PasteMethod · 0.45

Tested by

no test coverage detected