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

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.

主站蜘蛛池模板: 阿图什市| 师宗县| 呼图壁县| 达孜县| 古田县| 盐源县| 绥棱县| 灵山县| 杭锦后旗| 察哈| 敖汉旗| 靖西县| 辽源市| 清水河县| 隆回县| 项城市| 西和县| 垫江县| 凌云县| 常熟市| 武平县| 阿鲁科尔沁旗| 彭州市| 荣成市| 阿尔山市| 枣阳市| 茌平县| 泾川县| 江源县| 合阳县| 武乡县| 岚皋县| 洛浦县| 巫山县| 闻喜县| 沁源县| 双桥区| 思茅市| 岳普湖县| 南召县| 万荣县|