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"

How can I create a Blueprint Exposed Public access read-only, but private access read/write UProperty ?

Hello all,

I want to create a private variable that can be accessed "read only" from other class / blueprints.

In traditional C++ I would create private and make a public getter function but I am not sure if it's the true way to handle it in UE 4.

Is there a UProperty argument or specifier in UE 4 ?

Thanks, Atahan Bozkurt

Product Version: UE 4.11
more ▼

asked May 13 '16 at 03:00 PM in C++ Programming

avatar image

105 3 8 14

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

Make accessor/mutator getter/setter functions in the blueprint.

Other stuff requires going C++ mode on it.

In BP:

alt text

In C++: UProperties cannot be private. Use BP method.

Src: https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Reference/Properties/

Also see this subsection: https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Reference/Properties/Specifiers/BlueprintReadOnly/index.html

inbp.jpg (40.8 kB)
more ▼

answered May 13 '16 at 03:14 PM

avatar image

351 7 5 32

avatar image Lacridot May 16 '16 at 01:27 PM

I've made a accessor crosstable and I will upload soon.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

In C++ you can declare a private UPROPERTY but you'll get a compiler error or warning if you try to make it BlueprintReadOnly or BlueprintReadWrite. To get around this, you can specify explicitly that you allow a blueprint accessible variable to be private using this:

    UPROPERTY(BlueprintReadOnly, meta=(AllowPrivateAccess=true))
    bool MyPrivateValue;

So that makes a private variable accessible in blueprint. (My preference though is to declare the UPROPERTIES protected, since making a private variable read accessible already doesn't make it private.) To give access to it from other C++ classes, simply make public getter/setter functions.

more ▼

answered May 16 '16 at 07:24 PM

avatar image

Zhi Kang Shao
496 9 10 30

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

If I'm understanding correctly what you want, then this should do the trick for blueprints.

     type name;

For other C++ classes, you would need to make a getter function, as you regularly might. I would recommend against making any variables private to the C++ codebase, but if you really prefer that style don't forget to inline it :-)

more ▼

answered May 13 '16 at 04:09 PM

avatar image

447 35 36 67

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
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