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