Add Engine.FocusGameViewport to implement game menu with camera focus gather

This commit is contained in:
Wojciech Figat
2022-08-01 16:17:34 +02:00
parent 1d7e88635f
commit 7953f6cb83
7 changed files with 66 additions and 10 deletions

View File

@@ -409,6 +409,19 @@ JsonAsset* Engine::GetCustomSettings(const StringView& key)
return Content::LoadAsync<JsonAsset>(assetId);
}
void Engine::FocusGameViewport()
{
#if USE_EDITOR
Editor::Managed->FocusGameViewport();
#else
if (MainWindow)
{
MainWindow->BringToFront();
MainWindow->Focus();
}
#endif
}
bool Engine::HasGameViewportFocus()
{
#if USE_EDITOR

View File

@@ -153,6 +153,11 @@ public:
static Window* MainWindow;
/// <summary>
/// Brings focused to the game viewport (game can receive input).
/// </summary>
API_FUNCTION() static void FocusGameViewport();
/// <summary>
/// Checks whenever the game viewport is focused by the user (eg. can receive input).
/// </summary>