Skip to content

Instantly share code, notes, and snippets.

@sephirot47
Created June 30, 2015 14:32
Show Gist options
  • Save sephirot47/8e475b090d4314b6a628 to your computer and use it in GitHub Desktop.
Save sephirot47/8e475b090d4314b6a628 to your computer and use it in GitHub Desktop.
UE4 Get Viewport / Screen Size and Center
/*
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);
@YesIDont
Copy link

Another way to do it is like this:
const FVector2D ViewportSize = FVector2D(GEngine->GameUserSettings->GetLastConfirmedScreenResolution());

@Nikki-Old
Copy link

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment