Pointer to const data parameter in a BlueprintImplementableEvent

Hello,

I’m having some trouble trying to pass a pointer to const data in a BlueprintImplementableEvent, when I compile it and implement it in a blueprint it doesn’t prevent from modifying the const pointed object.


UFUNCTION(BlueprintImplementableEvent, meta = (BlueprintProtected = "true", DisplayName = "Function Initializer"))
    void FunctionInitializer(const UVectorFieldEditable* VectorField);

When I implement it in a blueprint instance is possible to call setter for the object variables without any error.

How can I declare this function in c++ to make the VectorField parameter readonly in blueprints?

Thanks

You can’t, bp doesn’t support const uobject pointers. You’d have to either hint the user to not modify it or make some kind of wrapper.

Surprised it even compiles to be honest. Epic like const-correctness about as much as they like namespaces.
If you’re super bothered about it, then as Zeblote says you’d need to wrap it - probably by creating a UInterface that only exposes non-modifying methods. It’s going to bloat your code horribly if you start doing that everywhere though.

1 Like