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

Posted 林清的Blogs

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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);

 

以上是关于UE4 中在 Actor 中动态 Create Component 与ChildActor 的 小笔记的主要内容,如果未能解决你的问题,请参考以下文章