Why are BlueprintGetter not visible?

Hi,

I tried to implement BlueprintGetter in UHealthComponent : public UActorComponent, but I am not able to call it from the Blueprint (see Screenshot):


I also tried closing and re-opening, clean re-built and directly in an ACharacter-derived class instead of a UActorComponent . Unfortunately without success.

According to this site https://unreal.gg-labs.com/quick-reference/the-ufunction-macro:

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?

Thanks!

User BlueprintReadWrite for the UPROPERTY and BlueprintCallable for the UFUNCTOIN

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.

right…ok…sorry to try to help

1 Like

Sorry I did not want to sound rude. Thank you for trying to help!

1 Like

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.

1 Like

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”.
BlueprintGetter
Thanks a lot! :slight_smile:

1 Like