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

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.

主站蜘蛛池模板: 松江区| 玉林市| 凤翔县| 理塘县| 三明市| 奉化市| 永德县| 和顺县| 沙河市| 高碑店市| 石阡县| 林口县| 浮山县| 河西区| 天水市| 仁布县| 吴旗县| 玉溪市| 屏山县| 淮阳县| 阿鲁科尔沁旗| 梓潼县| 哈密市| 鹤山市| 尖扎县| 牙克石市| 彩票| 镇远县| 政和县| 怀仁县| 沙湾县| 桃江县| 博客| 清流县| 周至县| 遂溪县| 汪清县| 德阳市| 马关县| 临城县| 务川|