I also tried closing and re-opening, clean re-built and directly in an ACharacter-derived class instead of a UActorComponent . Unfortunately without success.
BlueprintGetter
This function will be used as the accessor for a Blueprint-exposed property. This specifier implies BlueprintPure and BlueprintCallable.
I’d really like to follow encapsulation principles (instead of AllowPrivateAccess). Am I missing something or might that be a bug?
Sorry but how is this an answer to my question? With BlueprintReadWrite you are breaking encapsulation. Encapsulation is important to hide implementation details and to write clean interfaces between classes and users of the class. I intended to use a BlueprintGetter to follow such software design principles.
BlueprintGetters are more like overrides for the standard get method of BlueprintReadOnly variables. This allows you to make the additional checks or replication or whatever is necessary.
The UPROPERTY() is already implicitly BlueprintReadOnly when using BlueprintGetter = FunctionName.
Following from that, to “get” the variable in the blueprint graph with your current setup you would search for Alive, not IsAlive.
Though, if you used the coding standard, the variable would be named bIsAlive and the function name would be GetIsAlive.
Following from that, to “get” the variable in the blueprint graph with your current setup you would search for Alive, not IsAlive.
Though, if you used the coding standard, the variable would be named bIsAlive and the function name would be GetIsAlive.
Good to know! Also thanks for the hint to the naming convention. I just compiled the following, ignoring the naming conventions deliberately to test if Unreal derives any logic from it, which not seems to be the case:
public:
UFUNCTION(BlueprintGetter)
int GiveMeFoo() const { return Foo + 1; }
private:
UPROPERTY(BlueprintGetter=GiveMeFoo)
int Foo = 42;
No matter how I name the getter, the variable is accessed via Get Foo as you pointed out with “overrides”.