Edit C++ variables inside Unreal Editor using UPROPERTY

 


For example, adding an integer variable in an AMyActor class in the MyActor.h file:

int32 myInteger = 777;

Now if we want to access that variable in the Unreal Editor, we can precede the above declaration of myInteger with:

UPROPERTY(EditAnywhere)

Then we would have:

UPROPERTY(EditAnywhere)
int32 myInteger = 777;

Notice we don't put a semicolon after UPROPERTY(EditAnywhere) because it's part of the same declaration as the integer below.

Use UPROPERTY with it's property specifiers to control how the property behaves with various aspects of the Engine and Editor

The EditAnywhere specifier indicates that this property can be edited via property windows, archetypes and instances within the Editor.


For more information:

Unreal Engine 5 Documentation - Properties

Unreal Community Wiki - UPROPERTY