Unrecognized type 'FViewport'

I’m trying to take advantage of the ViewportResizedEvent and bind a function within a class that extends AHUD. I’ve tried to include UnrealClient.h with the same results. When I try and compile I get this error.

Unrecognized type 'FViewport' - type must be a UCLASS, USTRUCT or UENUM

My definition for the function is:

UFUNCTION()
void OnViewportResized(FViewport* ActiveViewport, uint32 UnknownUnsignedInt);

I’m binding it in the constructor:

GEngine->GameViewport->Viewport->ViewportResizedEvent.AddUObject(this, &ACustomHUD::OnViewportResized);

Hi HumbleByte

FViewport is not exposed to Unreal script and that is why UBT produces the error that you got, what you want to do is to remove the UFUNCTION() macro from your OnViewportResized function. AddUObject still works properly because the signature is not dynamic (Dynamic delegate needs to be function that is recognize by UBT, which is a UFunction, but non-dynamic delegate does not need to), it will keep a weak reference to the object and will still do all the safety check you would expect from a UObject delegate.

1 Like

Thanks! I figured the UFUNCTION() macro needed to be there! Now I know.