0
点赞
收藏
分享

微信扫一扫

UE4C++ 添加组件

践行数据分析 2022-01-15 阅读 52
ue4c++

构造函数中添加组件:

StaticMeshComponent =CreateDefaultSubobject<UStaticMeshComponent>(TEXT("StaitcMeshComponent"));

Runtime状态下添加组件:

//NewObject时一定要传入outer*,否则在编辑器中无法显示
StaticMeshComponent = NewObject<UStaticMeshComponent>(this,TEXT("StaticMeshComponent"));
this->AddOwnedComponent(StaticMeshComponent);
StaticMeshComponent->RegisterComponent();//重要
this->SetRootComponent(StaticMeshComponent);
举报

相关推荐

0 条评论