PIE 상태에서 뷰포트를 2개 이상 쓰는 경우 포커스 된 상태인지를 체크할 때 사용하면 됨.
Focused 여부는 SlateOperations 를 통해 업데이트 됨.
#if UE_EDITOR
UWorld* World = GetWorld();
if (IsValid(World) && World->WorldType == EWorldType::PIE)
{
UGameViewportClient* GameViewportClient = World->GetGameViewport();
if (!IsValid(GameViewportClient))
return;
if (IsValid(GEngine) && IsValid(GEngine->GameViewport) && (GEngine->GameViewport->Viewport != nullptr))
{
const bool bIsFocusedViewport = GameViewportClient->IsFocused(GEngine->GameViewport->Viewport);
UE_LOG(LogTemp, Log, TEXT("%s"), (bIsFocusedViewport ? TEXT("FOCUSED") : TEXT("NOT FOCUSED")));
}
}
#endif //UE_EDITOR
EN : https://bbagwang.github.io/2022/03/05/how-to-check-my-viewport-is-focused.html