本文整理汇总了C++中UActorComponent::IsCreatedByConstructionScript方法的典型用法代码示例。如果您正苦于以下问题:C++ UActorComponent::IsCreatedByConstructionScript方法的具体用法?C++ UActorComponent::IsCreatedByConstructionScript怎么用?C++ UActorComponent::IsCreatedByConstructionScript使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UActorComponent
的用法示例。
在下文中一共展示了UActorComponent::IsCreatedByConstructionScript方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DestroyConstructedComponents
//* Destroys the constructed components.
void AActor::DestroyConstructedComponents()
{
// Remove all existing components
TInlineComponentArray<UActorComponent*> PreviouslyAttachedComponents;
GetComponents(PreviouslyAttachedComponents);
// We need the hierarchy to be torn down in attachment order, so do a quick sort
PreviouslyAttachedComponents.Remove(nullptr);
PreviouslyAttachedComponents.Sort([](UActorComponent& A, UActorComponent& B)
{
if (USceneComponent* BSC = Cast<USceneComponent>(&B))
{
if (BSC->AttachParent == &A)
{
return false;
}
}
return true;
});
for (UActorComponent* Component : PreviouslyAttachedComponents)
{
if (Component)
{
bool bDestroyComponent = false;
if (Component->IsCreatedByConstructionScript())
{
bDestroyComponent = true;
}
else
{
UActorComponent* OuterComponent = Component->GetTypedOuter<UActorComponent>();
while (OuterComponent)
{
if (OuterComponent->IsCreatedByConstructionScript())
{
bDestroyComponent = true;
break;
}
OuterComponent = OuterComponent->GetTypedOuter<UActorComponent>();
}
}
if (bDestroyComponent)
{
if (Component == RootComponent)
{
RootComponent = NULL;
}
Component->DestroyComponent();
// Rename component to avoid naming conflicts in the case where we rerun the SCS and name the new components the same way.
FName const NewBaseName( *(FString::Printf(TEXT("TRASH_%s"), *Component->GetClass()->GetName())) );
FName const NewObjectName = MakeUniqueObjectName(this, GetClass(), NewBaseName);
Component->Rename(*NewObjectName.ToString(), this, REN_ForceNoResetLoaders|REN_DontCreateRedirectors|REN_NonTransactional);
}
}
}
}
示例2: if
FTransaction::FObjectRecord::FReferencedObject::FReferencedObject(UObject* InObject)
{
UActorComponent* Component = Cast<UActorComponent>(InObject);
UObject* CDO = nullptr;
if (Component && OuterIsCDO(Component, CDO))
{
Object = CDO;
ComponentName = Component->GetFName();
}
else if (Component && Component->IsCreatedByConstructionScript())
{
Object = Component->GetOuter();
ComponentName = Component->GetFName();
}
else
{
Object = InObject;
}
}
示例3: RerunConstructionScripts
//.........这里部分代码省略.........
for (const auto& CachedAttachInfo : ActorTransactionAnnotation->RootComponentData.AttachedToInfo)
{
AActor* AttachedActor = CachedAttachInfo.Actor.Get();
if (AttachedActor)
{
FAttachedActorInfo Info;
Info.AttachedActor = AttachedActor;
Info.AttachedToSocket = CachedAttachInfo.SocketName;
Info.bSetRelativeTransform = true;
Info.RelativeTransform = CachedAttachInfo.RelativeTransform;
AttachedActorInfos.Add(Info);
AttachedActor->DetachRootComponentFromParent();
}
}
bUseRootComponentProperties = false;
}
}
else
#endif
{
InstanceDataCache = new FComponentInstanceDataCache(this);
// If there are attached objects detach them and store the socket names
TArray<AActor*> AttachedActors;
GetAttachedActors(AttachedActors);
for (AActor* AttachedActor : AttachedActors)
{
USceneComponent* EachRoot = AttachedActor->GetRootComponent();
// If the component we are attached to is about to go away...
if (EachRoot && EachRoot->AttachParent && EachRoot->AttachParent->IsCreatedByConstructionScript())
{
// Save info about actor to reattach
FAttachedActorInfo Info;
Info.AttachedActor = AttachedActor;
Info.AttachedToSocket = EachRoot->AttachSocketName;
Info.bSetRelativeTransform = false;
AttachedActorInfos.Add(Info);
// Now detach it
AttachedActor->Modify();
EachRoot->DetachFromParent(true);
}
}
}
if (bUseRootComponentProperties && RootComponent != nullptr)
{
// Do not need to detach if root component is not going away
if (RootComponent->AttachParent != NULL && RootComponent->IsCreatedByConstructionScript())
{
Parent = RootComponent->AttachParent->GetOwner();
// Root component should never be attached to another component in the same actor!
if (Parent == this)
{
UE_LOG(LogActor, Warning, TEXT("RerunConstructionScripts: RootComponent (%s) attached to another component in this Actor (%s)."), *RootComponent->GetPathName(), *Parent->GetPathName());
Parent = NULL;
}
ParentComponent = RootComponent->AttachParent;
SocketName = RootComponent->AttachSocketName;
//detach it to remove any scaling
RootComponent->DetachFromParent(true);
}
示例4: if
//.........这里部分代码省略.........
bool bIsOkToReuse = ComponentTemplate->GetClass() == TemplateClass
&& ComponentTemplate->GetOuter() == SubobjectOuter
&& ComponentTemplate->GetFName() == TemplateName
&& (ComponentTemplate->GetArchetype() == Archetype || !Archetype);
if (!bIsOkToReuse)
{
UE_LOG(LogEditorObject, Log, TEXT("Could not reuse component instance %s, name clash?"), *ComponentTemplate->GetFullName());
ComponentTemplate->Rename(); // just abandon the existing component, we are going to create
OldComponent = ComponentTemplate;
ComponentTemplate = NULL;
}
}
if (!ComponentTemplate)
{
ComponentTemplate = NewObject<UObject>(
SubobjectOuter,
TemplateClass,
TemplateName,
NewFlags,
Archetype,
!!SubobjectOuter,
&InstanceGraph
);
}
else
{
// We do not want to set RF_Transactional for construction script created components, so we have to monkey with things here
if (NewFlags & RF_Transactional)
{
UActorComponent* Component = Cast<UActorComponent>(ComponentTemplate);
if (Component && Component->IsCreatedByConstructionScript())
{
NewFlags &= ~RF_Transactional;
}
}
// Make sure desired flags are set - existing object could be pending kill
ComponentTemplate->ClearFlags(RF_AllFlags);
ComponentTemplate->SetFlags(NewFlags);
}
// replace all properties in this subobject outer' class that point to the original subobject with the new subobject
TMap<UObject*, UObject*> ReplacementMap;
if (Archetype)
{
checkSlow(ComponentTemplate->GetArchetype() == Archetype);
ReplacementMap.Add(Archetype, ComponentTemplate);
InstanceGraph.AddNewInstance(ComponentTemplate);
}
if (OldComponent)
{
ReplacementMap.Add(OldComponent, ComponentTemplate);
}
FArchiveReplaceObjectRef<UObject> ReplaceAr(SubobjectOuter, ReplacementMap, false, false, true);
// import the properties for the subobject
SourceText = ImportObjectProperties(
(uint8*)ComponentTemplate,
SourceText,
TemplateClass,
SubobjectRoot,
ComponentTemplate,
Warn,