Creating a UENUM( )
C++ enum
are very useful in typical C++ code. UE4 has a custom type of enumeration called UENUM()
, which allows you to create an enum
that will show up in a drop-down menu inside a Blueprint that you are editing.
How to do it...
- Go to the header file that will use the
UENUM()
you are specifying, or create a fileEnumName.h
. - Use code of the form:
UENUM() enum Status { Stopped UMETA(DisplayName = "Stopped"), Moving UMETA(DisplayName = "Moving"), Attacking UMETA(DisplayName = "Attacking"), };
- Use your
UENUM()
in aUCLASS()
as follows:UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Status) TEnumAsByte<Status> status;
How it works…
UENUM()
show up nicely in the code editor as drop-down menus in the Blueprints editor from which ...
Get Unreal Engine 4 Scripting with C++ Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.