【UE4 C++ 基础知识】<4> 枚举 Enum、结构体 Struct
枚举
UENUM宏搭配BlueprintType可以将枚举暴露给蓝图,不使用的话,仅能在C++使用
//定义一个原生enum class
enum class EMyType
{
Type1,
Type2,
Type3,
};
UENUM(BlueprintType)
enum class ECurrentState : uint8
{
Idle UMETA(DisplayName="空闲"),
Attack UMETA(DisplayName="攻击"),
Roll UMETA(DisplayName="翻滚"),
Dead UMETA(DisplayName="死亡"),
};
UPROPERTY(EditAnywhere,BlueprintReadWrite)
ECurrentState MyCurrentState UMETA(DisplayName = "当前状态");

结构体
BlueprintType可以将枚举暴露给蓝图
//结构体
USTRUCT(BlueprintType)
struct FMyStruct
{
GENERATED_BODY()
// 暴露给蓝图
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Test Variables")
int32 MyIntegerMemberVariable;
// 不暴露给蓝图
int32 NativeOnlyMemberVariable;
// 蓝图图表无法访问此UObject指针,但是指针对UE4的反射、智能指针和垃圾回收系统可见。
UPROPERTY()
UObject* SafeObjectPointer;
};
UPROPERTY(EditAnywhere,BlueprintReadWrite)
FMyStruct MyStruct;

- 继承
FTableRowBase之后可以用于DataTable
struct FInventoryItemInfo : public FTableRowBase
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FString ItemName UMETA(DisplayName="名称");
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 index UMETA(DisplayName="编号");
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bCanStaking UMETA(DisplayName="可否叠加");
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 Count UMETA(DisplayName="数量");
UPROPERTY(EditAnywhere, BlueprintReadWrite)
UTexture2D* Icon UMETA(DisplayName="图标");
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TSubclassOf<AActor> ItemClass;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
USkeletalMesh* SkeletalMesh;
};
UPROPERTY(EditAnywhere,BlueprintReadWrite)
FInventoryItemInfo EmptyItem;

参考
【UE4 C++ 基础知识】<4> 枚举 Enum、结构体 Struct的更多相关文章
- swift:入门知识之枚举和结构体
枚举: swift中的枚举有些类似于类这个概念,它有自己的属性,也可以有自己的方法 枚举中的成员有原始值和实际值之分,原始值用来枚举成员的排序次序,默认从0开始 枚举出来的成员值就是实际值 可以通过t ...
- C# 篇基础知识2——运算符、类型转换、流程控制、枚举、结构体和数组、函数
1.运算符.类型转换 计算某年y某月m某日d是周几的基姆拉尔森公式公式:int week = (d + 2*m + 3*(m + 1)/5 + y + y/4 - y/100 + y/400 + 1) ...
- 【UE4 C++ 基础知识】<11>资源的同步加载与异步加载
同步加载 同步加载会造成进程阻塞. FObjectFinder / FClassFinder 在构造函数加载 ConstructorHelpers::FObjectFinder Constructor ...
- 结构体struct、联合体union、枚举类型enum
1.c语言中的类型 1)内置类型——char,short,int,float,double: 2)用户自定义类型(UDT)——struct结构体,union联合体,enum枚举类型 2.内存对齐 2. ...
- Swift具体解释之六----------------枚举、结构体、类
枚举.结构体.类 注:本文为作者自己总结.过于基础的就不再赘述 ,都是亲自測试的结果.如有错误或者遗漏的地方.欢迎指正,一起学习. 1.枚举 枚举是用来定义一组通用类型的一组相关值 ,关键字enum ...
- Swift中元组(Tuples),结构体(Struct),枚举(Enums)之间的区别
Swift有许多种存储数据方式,你可以用枚举(enums),元组(tuples),结构体(structs),类(classes),在这篇文章中我们将比较枚举.元组.结构体之间区别,首先从最简单的开始- ...
- c#之枚举,结构体
1.枚举 2.结构体 例子1: using System; using System.Collections.Generic; using System.Linq; using System.Text ...
- swift学习笔记之---数组、字典、枚举、结构体
1.数组-Array let types = ["none","warning","error"] //省略类型的数组声明 let menb ...
- swift 定义枚举和结构体 及使用
//定义枚举 enum MapDirection { case North case South case East case West func simpleDescription() -> ...
- 结构体struct知识
2022-10-12 08:52:03 // 结构体知识#define _CRT_SECURE_NO_WARNINGS 1#include<stdio.h>#include<m ...
随机推荐
- Python3正则表达式学习笔记
学习前准备:导入re模块 import re 一.re的核心函数 1 - re.compile(pattern[, flags]) 编译正则表达式,速度快 2 - re.match(pattern, ...
- jQuery扩展方法 (插件机制)
jQuery.extend(object) 扩展jQuery对象本身. 用来在jQuery命名空间上增加新函数. 在jQuery命名空间上增加两个函数: <script> jQuery.e ...
- C# 给PPT中的图表添加趋势线
本文内容分享通过C#程序代码给PPT文档中的图表添加数据趋势线的方法. 支持趋势线的图表类型包括二维面积图.条形图.柱形图.柱形图.股价图.xy (散点图) 和气泡图中:不能向三维.堆积.雷达图.饼图 ...
- Robot Framework(10)- 使用资源文件
如果你还想从头学起Robot Framework,可以看看这个系列的文章哦! https://www.cnblogs.com/poloyy/category/1770899.html 啥是资源文件 资 ...
- CSS003. 盒子水平垂直居中简写属性(place-items)
place-items CSS 中的 place-items 是一个简写属性 ,它允许你在相关的布局(如 Grid 或 Flexbox)中可以同时沿着块级和内联方向对齐元素 (例如:align-it ...
- 一文读懂Redis
目录结构如下: 简介 Redis是一个高性能的key-value数据库.Redis对数据的操作都是原子性的. 优缺点 优点: 基于内存操作,内存读写速度快. Redis是单线程的,避免线程切换开销及多 ...
- POJ3625Building Roads
Building Roads Description Farmer John had just acquired several new farms! He wants to connect the ...
- nuxt.js同路由跳转参数不同,mounted不执行时
watch: { '$route'(to, from) { if (to.fullPath !== from.fullPath) { this.$nextTick(() => { // 不加th ...
- Linux系列(4) - 目录处理命令(1)
前言 linux中一切皆文件.目录为目录文件,普通文件用来保存数据,目录文件用来保存文件 建立目录:mkdir mkdir -p [目录名] -p 递归创建目录,例子:mkdir -p LinuxTe ...
- PHP 7.4 checking for libzip 和 failed to open error_log 问题
来源: https://hqidi.com/154.html 两个深坑,成年阿根廷龙踩出来的坑,网上都没找到解决方法,都是自己摸索出来的. 前面一切顺利: yum install -y libxml2 ...