GENERATED_BODY() macro

I saw this statement in UObject Instance Creation | Unreal Engine Documentation

I then created a C++ project from the “block template” project. In my PlayerController header file, I made something like this:

The following statement does not have access specifiers (private/protected/public).

UPROPERTY(BlueprintReadWrite, EditAnywhere)
UTexture2D* mCustomTexture;

But based on the documentation, the GENERATED_BODY() macro should give public access specifiers to all member variables by default. Oddly, when I compile the project in VS, it showed this error:

BlueprintReadWrite should not be used on private members

I thought that member variable should be public by default because there’s the GENERATED_BODY() macro. Is this a bug in UE4?

Could you explain why the macro and the compiler does not sync?

Hey Pelangi-

The previous macro in place of GENERATED_BODY was GENERATED_UCLASS_BODY(). This macro did give public access to variables by default. It appears that the documentation was not updated when the switch to GENERATED_BODY was made. Thank you for pointing this out, I have entered a ticket to update the documentation. As for the code, GENERATED_BODY() has private access by default, so you would need to add public: below it to give your pointers public access.

Cheers