#How to Get Viewport Size and Center From Anywhere
Here’s how you can get the viewport size and center from anywhere in your code base!
//Viewport Size
const FVector2D ViewportSize = FVector2D(GEngine->GameViewport->Viewport->GetSizeXY());
//Viewport Center!
const FVector2D ViewportCenter = FVector2D(ViewportSize.X/2, ViewportSize.Y/2);
#Engine.h not EngineMinimal
To be able to use the above code replace this in YourProject.h
#include "EngineMinimal.h"
with
#include "Engine.h"
Enjoy!