x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

GENERATED_BODY() macro

I saw this statement in https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Objects/index.html

alt text

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

alt text

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?

Product Version: UE 4.11
Tags:
ue4 docs.jpg (45.7 kB)
compilation.jpg (231.9 kB)
more ▼

asked Jun 09 '16 at 07:20 AM in C++ Programming

avatar image

Pelangi
233 19 32 40

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

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

Doug Wilson

more ▼

answered Jun 09 '16 at 01:52 PM

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question