Get Viewport Size directly into FVector2D. C++

Parameters are passed by reference there’s no way it could work with float/double as int32.

FVector is simply an instantiation of TVector with the explicit type double :

image

So you could kinda gain some lines in the following way :

UE::Math::TVector2<int32> Vec;
GetViewportSize(Vec.X, Vec.Y);

However be aware that this is NOT an FVector2D, it is a 2d vector of int32, they are not directly interchangeable/convertible, and most common vector operations will probably not work correctly with int32 operators. But if you just need the variables then it may work. It’s essentially equivalent to this :

int32 SizeX, SizeY;
GetViewportSize(SizeX, SizeY);
1 Like