创建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);
时间: 2024-10-09 22:56:52