Created
June 30, 2015 14:32
-
-
Save sephirot47/8e475b090d4314b6a628 to your computer and use it in GitHub Desktop.
UE4 Get Viewport / Screen Size and Center
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
IMPORTANT! | |
In order to be able to use this functions, in the file "YourProject.h" change this: | |
#include "EngineMinimal.h" | |
For this: | |
#include "Engine.h" | |
*/ | |
//Viewport Size | |
const FVector2D ViewportSize = FVector2D(GEngine->GameViewport->Viewport->GetSizeXY()); | |
//Viewport Center! | |
const FVector2D ViewportCenter = FVector2D(ViewportSize.X/2, ViewportSize.Y/2); |
A little more specific (maybe better include-what-you-use for better build times?): #include "Engine/Engine.h"
Another way to do it is like this:
const FVector2D ViewportSize = FVector2D(GEngine->GameUserSettings->GetLastConfirmedScreenResolution());
Thank you!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you, this was still helpful 5 years later.