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

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.

主站蜘蛛池模板: 石柱| 天门市| 五华县| 固始县| 东城区| 万年县| 台安县| 灵武市| 通化市| 长兴县| 象州县| 长寿区| 宜兴市| 榕江县| 淮安市| 华安县| 永福县| 德阳市| 宜兴市| 清远市| 金坛市| 枣强县| 阿拉善盟| 靖西县| 施秉县| 辰溪县| 霞浦县| 渭南市| 武胜县| 邳州市| 绥滨县| 鹿泉市| 武义县| 海兴县| 金山区| 米脂县| 乳山市| 客服| 和政县| 灵山县| 盈江县|