Unreal Engine – Exposing Functions and Variables to the Editor

This is a repost of something I put on twitter a while ago when I first started learning Unreal Engine last year which was how intuitive it was to expose things to the editor. Unity lets you expose variables to the editor by using the SerializedField attribute. Unreal Engine has a similar method in the form of UProperty.

I have shamelessly stolen the example from the Unreal Wiki (for context this is here as part of my notes as well as a reference for anyone else), but if you do the following:

//How long, in seconds, the countdown will run
UPROPERTY(EditAnywhere)
int32 CountdownTime;

You will see the variable appear in the editor:

Also, you see there are comments in the code. These also get exposed to the editor.

Neat.

 

What is even cooler is you can expose your own code in the blueprint system. I love the blueprint system, it is powerful and is great for visualising the logic.

In one of my older projects, I had a need to expose the move direction of the player. By adding the UFUNCTION macro with the BlueprintCallable argument it is exposed to the blueprint system!

You can find out more about this on the Unreal Wiki:

https://docs.unrealengine.com/en-us/Programming/Tutorials/VariablesTimersEvents/2

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

Verify that you are not a robot! (If you are unlucky) *