Download

UFunctions cannot take a TObjectPtr as a parameter. Why?

I have a method:

UFUNCTION()
void SpawnLoadedActors(TObjectPtr<UGnarlGameInstance> GameInstance);

This gives a compiler error: UFunctions cannot take a TObjectPtr as a parameter.

If I remove UFUNCTION(), it compiles fine.

I admit that I don’t understand when to use UFUNCTION and when not to… something about the reflection system… which as far as I can tell allows the function to be called/implemented in blueprints, and use in timers and delegates.

So why wouldn’t I want a function that takes a TObjectPtr as a parameter to be noticed by the reflection system? I’m probably missing something fundamental here, so I appreciate your patience.

Any tips on when and when not to use UFUNCTION or UPROPERTY are also welcome.

2 Likes