A few tips about UPROPERTY

Hello!

I’m really enjoying this lesson :smiley:

Looking at the UE4 documentation, UPROPERTY allows you to specify various Metadata Specifiers that are really useful.

For example, in this lecture we expose the DoorCloseDelay property to the editor. You can add a tooltip so you know what it is really doing like this:

	UPROPERTY(EditAnywhere, meta=(ToolTip="The speed at which the door closes, in seconds."))
	float DoorCloseDelay = 0.5f;

And in the editor:

image

Also, in this lecture Mike is changing the member variable named TargetYawto OpenAngle (and renaming all occurrences of this variable in the .cpp file). Although it’s not exactly the same as renaming the variable in the code, you can expose a different name in the editor by using the DisplayName metadata:

	UPROPERTY(EditAnywhere, meta=(DisplayName="OpenAngle", Tooltip="Target angle - in degrees - when the door is fully opened."))
	float TargetYaw = 90.f;

image

There are a lot of possible combinations, so be sure to check the documentation.

5 Likes

Really useful! Thanks!

I just discovered that Unreal is smart enough to pick up the tool tip without any metadata specifiers too. You can just place a comment block above the line of code and it’ll do the work for you.

For example, the following will generate the same tool tip when you hover over the property:

/*The speed at which the door closes, in seconds.*/
UPROPERTY(EditAnywhere)
float DoorCloseDelay = 0.5f;

I can’t find a faster way to change the display name though.

2 Likes

Thanks , good to know.

Thanks!

Privacy & Terms