Download

Return a const pointer from BlueprintImplementableEvent to C++

Initially I created BlueprintImplementableEvent function with signature as show below.


UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "SpawnFloorBlock"), Category = "FloorBlock")
		AFloorBlock * SpawnFloorBlock(const FVector pPosition);

Where AFloorBlock is a class that inherits AActor.

Now I want to make this function following better programming standards so I changed the signature to


UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "SpawnFloorBlock"), Category = "FloorBlock")
		const AFloorBlock * SpawnFloorBlock(const FVector &pPosition);

Compile the project gives the following error.

Does this mean that BlueprintImplementableEvent can never return a const pointer?
I’m very new to unreal and using blueprint make its easy for me to learn unreal, but this is limiting me from creating better codes. I do prefer to write entire code in C++ without using blueprints but with my current knowledge it seems like a impossible task.
Or is there a way of doing this and I just don’t know it yet?

EDIT: I’m able to open the generated.cpp and change the signature there and when I compile it works. But when I close the unreal and open it again the function signature in generated.cpp changes back to returning non const pointer

Not possible, Blueprint doesn’t really care so much about const correct-ness - but it’s an artist tool.

You should also never edit the generated files.