Skip to Content
Unreal Engine 4 Scripting with C++ Cookbook
book

Unreal Engine 4 Scripting with C++ Cookbook

by Stephen Whittle, William Sherif
October 2016
Intermediate to advanced
452 pages
9h 47m
English
Packt Publishing
Content preview from Unreal Engine 4 Scripting with C++ Cookbook

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...

  1. Go to the header file that will use the UENUM() you are specifying, or create a file EnumName.h.
  2. Use code of the form:
    UENUM()
    enum Status
    {
      Stopped     UMETA(DisplayName = "Stopped"),
      Moving      UMETA(DisplayName = "Moving"),
      Attacking   UMETA(DisplayName = "Attacking"),
    };
  3. Use your UENUM() in a UCLASS() 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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Unreal Engine 4.x Scripting with C++ Cookbook - Second Edition

Unreal Engine 4.x Scripting with C++ Cookbook - Second Edition

John P. Doran, William Sherif, Stephen Whittle

Publisher Resources

ISBN: 9781785885549Supplemental Content