UE4 中在 Actor 中动态 Create Component 与ChildActor 的 小笔记

创建Component:

UCpp_MyComponent* temp_imageCom = NewObject<UCpp_MyComponent>(this, UCpp_MyComponent::StaticClass());
temp_imageCom->RegisterComponent();
temp_imageCom->AttachToComponent(pParentComponent, FAttachmentTransformRules::KeepRelativeTransform);

 

创建Actor Component:

仅多了一步SetChildActorClass

auto temp_childActorComponent = NewObject<UChildActorComponent>(this, UChildActorComponent::StaticClass());
temp_imageCom->RegisterComponent();
temp_childActorComponent->SetChildActorClass(*MyActorClass);
temp_imageCom->AttachToComponent(pParentComponent, FAttachmentTransformRules::KeepRelativeTransform);

 

文章来自:http://www.cnblogs.com/linqing/p/5979939.html
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3