欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

UE4 chapter2

程序员文章站 2022-06-10 23:33:37
...

UCLASS

  • Blueprintable 可创建蓝图
  • BlueprintType 可作为蓝图变量
  • NotBlueprintType 不可作为蓝图变量

UPROPERTY

  • EditAnywhere 蓝图类和实例可编辑
    • EditDefaultsOnly 蓝图类可编辑
    • EditInstanceOnly 实例可编辑
  • BlueprintReadWrite 蓝图类可读可写get/set
    • BlueprintReadOnly 蓝图类可读get
    • BlueprintWriteOnly 蓝图类可写set

创建和销毁UCLASS

UUserProfile* newobject = NewObject<UUserProfile>(GetTransientPackage(), UUserProfile::StaticClass());
if (newobject)
{ 
	newobject->ConditionalBeginDestroy();
	newobject = nullptr; 
}

强制内存回收
GetWorld()->ForceGarbageCollection( true );

创建结构体

USTRUCT()
struct xxx_API FColoredTexture
{
	GENERATED_USTRUCT_BODY()
public:
  UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = HUD )
  UTexture* Texture;
  UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = HUD )    
  FLinearColor Color;
};

创建枚举

UENUM()
enum Status
{
  Stopped UMETA(DisplayName = "Stopped"),
  Moving UMETA(DisplayName = "Moving"),
  Attacking UMETA(DisplayName = "Attacking"),
};
相关标签: UE4 UE4