官术网_书友最值得收藏!

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 you can only select one of a few values.

主站蜘蛛池模板: 琼结县| 浠水县| 玛曲县| 蒙山县| 紫云| 凉城县| 连城县| 临安市| 远安县| 中江县| 驻马店市| 耒阳市| 周口市| 溧水县| 迁安市| 横山县| 古田县| 定西市| 佛冈县| 土默特左旗| 河东区| 九龙坡区| 缙云县| 浙江省| 定兴县| 福安市| 资溪县| 阿拉善左旗| 文山县| 普洱| 新乐市| 贵南县| 定襄县| 全南县| 治县。| 金川县| 班玛县| 禄丰县| 拜城县| 宁夏| 收藏|