本文整理汇总了C++中TInlineComponentArray::RemoveAt方法的典型用法代码示例。如果您正苦于以下问题:C++ TInlineComponentArray::RemoveAt方法的具体用法?C++ TInlineComponentArray::RemoveAt怎么用?C++ TInlineComponentArray::RemoveAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TInlineComponentArray
的用法示例。
在下文中一共展示了TInlineComponentArray::RemoveAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExecuteScriptOnActor
void USimpleConstructionScript::ExecuteScriptOnActor(AActor* Actor, const FTransform& RootTransform, bool bIsDefaultTransform)
{
if(RootNodes.Num() > 0)
{
TSet<UActorComponent*> AllComponentsCreatedBySCS;
TInlineComponentArray<UActorComponent*> InstancedComponents;
for(auto NodeIt = RootNodes.CreateIterator(); NodeIt; ++NodeIt)
{
USCS_Node* RootNode = *NodeIt;
if(RootNode != nullptr)
{
// Get all native scene components
TInlineComponentArray<USceneComponent*> Components;
Actor->GetComponents(Components);
for (int32 Index = Components.Num()-1; Index >= 0; --Index)
{
USceneComponent* SceneComponent = Components[Index];
if (SceneComponent->CreationMethod == EComponentCreationMethod::Instance)
{
Components.RemoveAt(Index);
}
else
{
// Handle the native sub-component of an instance component case
USceneComponent* ParentSceneComponent = SceneComponent->GetTypedOuter<USceneComponent>();
if (ParentSceneComponent && ParentSceneComponent->CreationMethod == EComponentCreationMethod::Instance)
{
Components.RemoveAt(Index);
}
}
}
// Get the native root component; if it's not set, the first native scene component will be used as root. This matches what's done in the SCS editor.
USceneComponent* RootComponent = Actor->GetRootComponent();
if(RootComponent == nullptr && Components.Num() > 0)
{
RootComponent = Components[0];
}
// If the root node specifies that it has a parent
USceneComponent* ParentComponent = nullptr;
if(RootNode->ParentComponentOrVariableName != NAME_None)
{
// Get the Actor class object
UClass* ActorClass = Actor->GetClass();
check(ActorClass != nullptr);
// If the root node is parented to a "native" component (i.e. in the 'Components' array)
if(RootNode->bIsParentComponentNative)
{
for(int32 CompIndex = 0; CompIndex < Components.Num(); ++CompIndex)
{
// If we found a match, remember the index
if(Components[CompIndex]->GetFName() == RootNode->ParentComponentOrVariableName)
{
ParentComponent = Components[CompIndex];
break;
}
}
}
else
{
// In the non-native case, the SCS node's variable name property is used as the parent identifier
UObjectPropertyBase* Property = FindField<UObjectPropertyBase>(ActorClass, RootNode->ParentComponentOrVariableName);
if(Property != nullptr)
{
// If we found a matching property, grab its value and use that as the parent for this node
ParentComponent = Cast<USceneComponent>(Property->GetObjectPropertyValue_InContainer(Actor));
}
}
}
// Create the new component instance and any child components it may have
UActorComponent* InstancedComponent = RootNode->ExecuteNodeOnActor(Actor, ParentComponent != nullptr ? ParentComponent : RootComponent, &RootTransform, bIsDefaultTransform);
if(InstancedComponent != nullptr)
{
InstancedComponents.Add(InstancedComponent);
}
// get list of every component SCS created, in case some of them aren't in the attachment hierarchy any more (e.g. rigid bodies)
TInlineComponentArray<USceneComponent*> ComponentsAfterSCS;
Actor->GetComponents(ComponentsAfterSCS);
for (USceneComponent* C : ComponentsAfterSCS)
{
if (Components.Contains(C) == false)
{
AllComponentsCreatedBySCS.Add(C);
}
}
}
}
// Register all instanced SCS components once SCS execution has finished; sorted in order to register the scene component hierarchy first, followed by the remaining actor components (in case they happen to depend on something in the scene hierarchy)
InstancedComponents.Sort([](const UActorComponent& A, const UActorComponent& B) { return A.IsA<USceneComponent>(); });
for(auto InstancedComponent : InstancedComponents)
{
RegisterInstancedComponent(InstancedComponent);
}
// now that the instanced components in the attachment hierarchy are registered, register any other components that SCS made but aren't in the attachment hierarchy for whatever reason.
//.........这里部分代码省略.........