当前位置: 首页>>代码示例>>C++>>正文


C++ USceneComponent::DetachFromParent方法代码示例

本文整理汇总了C++中USceneComponent::DetachFromParent方法的典型用法代码示例。如果您正苦于以下问题:C++ USceneComponent::DetachFromParent方法的具体用法?C++ USceneComponent::DetachFromParent怎么用?C++ USceneComponent::DetachFromParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在USceneComponent的用法示例。


在下文中一共展示了USceneComponent::DetachFromParent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DetachActorFromParent

void FActorDropTarget::DetachActorFromParent(AActor* ChildActor)
{
	USceneComponent* RootComp = ChildActor->GetRootComponent();
	if (RootComp && RootComp->AttachParent)
	{
		AActor* OldParent = RootComp->AttachParent->GetOwner();
		OldParent->Modify();
		RootComp->DetachFromParent(true);
		ChildActor->SetFolderPath(OldParent->GetFolderPath());
	}
}
开发者ID:Codermay,项目名称:Unreal4,代码行数:11,代码来源:ActorTreeItem.cpp

示例2: SetFolderPath

void AActor::SetFolderPath(const FName& NewFolderPath, bool bDetachFromParent)
{
	// Detach the actor if it is attached
	USceneComponent* RootComp = GetRootComponent();
	const bool bIsAttached = RootComp  && RootComp->AttachParent;

	if (NewFolderPath == FolderPath && !bIsAttached)
	{
		return;
	}

	Modify();

	FName OldPath = FolderPath;
	FolderPath = NewFolderPath;
	
	// Detach the actor if it is attached
	if (bIsAttached && bDetachFromParent)
	{
		AActor* OldParentActor = RootComp->AttachParent->GetOwner();
		OldParentActor->Modify();

		RootComp->DetachFromParent(true);
	}

	if (GEngine)
	{
		GEngine->BroadcastLevelActorFolderChanged(this, OldPath);
	}

	//recursively change folder path for children (but do not detach so they remain as child)
	if(RootComp)
	{
		for(auto ChildSceneComponent : RootComp->AttachChildren)
		{
			AActor* ChildActor = ChildSceneComponent ? ChildSceneComponent->GetOwner() : nullptr;
			if(ChildActor)
			{
				ChildActor->SetFolderPath(NewFolderPath, false);
			}
		}
	}
}
开发者ID:Foreven,项目名称:Unreal4-1,代码行数:43,代码来源:ActorEditor.cpp

示例3: CacheChildAttachments

void FActorReplacementHelper::CacheChildAttachments(const AActor* OldActor)
{
	TArray<AActor*> AttachedActors;
	OldActor->GetAttachedActors(AttachedActors);

	// if there are attached objects detach them and store the socket names
	for (AActor* AttachedActor : AttachedActors)
	{
		USceneComponent* AttachedActorRoot = AttachedActor->GetRootComponent();
		if (AttachedActorRoot && AttachedActorRoot->AttachParent)
		{
			// Save info about actor to reattach
			FAttachedActorInfo Info;
			Info.AttachedActor = AttachedActor;
			Info.AttachedToSocket = AttachedActorRoot->AttachSocketName;
			PendingChildAttachments.Add(Info);

			// Now detach it
			AttachedActorRoot->DetachFromParent(/*bMaintainWorldPosition =*/true);
		}
	}
}
开发者ID:Codermay,项目名称:Unreal4,代码行数:22,代码来源:KismetReinstanceUtilities.cpp

示例4: RerunConstructionScripts


//.........这里部分代码省略.........
						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);
			}

			OldTransform = RootComponent->ComponentToWorld;
			OldTransform.SetTranslation(RootComponent->GetComponentLocation()); // take into account any custom location
		}

#if WITH_EDITOR
		// Save the current construction script-created components by name
		TMap<const FName, UObject*> DestroyedComponentsByName;
		TInlineComponentArray<UActorComponent*> PreviouslyAttachedComponents;
		GetComponents(PreviouslyAttachedComponents);
		for (auto Component : PreviouslyAttachedComponents)
开发者ID:johndpope,项目名称:UE4,代码行数:67,代码来源:ActorConstruction.cpp

示例5: RerunConstructionScripts

void AActor::RerunConstructionScripts()
{
	// don't allow (re)running construction scripts on dying actors
	bool bAllowReconstruction = !IsPendingKill() && !HasAnyFlags(RF_BeginDestroyed|RF_FinishDestroyed);
#if WITH_EDITOR
	if(bAllowReconstruction && GIsEditor)
	{
		// Generate the blueprint hierarchy for this actor
		TArray<UBlueprint*> ParentBPStack;
		bAllowReconstruction = UBlueprint::GetBlueprintHierarchyFromClass(GetClass(), ParentBPStack);
		if(bAllowReconstruction)
		{
			for(int i = ParentBPStack.Num() - 1; i > 0 && bAllowReconstruction; --i)
			{
				const UBlueprint* ParentBP = ParentBPStack[i];
				if(ParentBP && ParentBP->bBeingCompiled)
				{
					// don't allow (re)running construction scripts if a parent BP is being compiled
					bAllowReconstruction = false;
				}
			}
		}
	}
#endif
	if(bAllowReconstruction)
	{
		// Temporarily suspend the undo buffer; we don't need to record reconstructed component objects into the current transaction
		ITransaction* CurrentTransaction = GUndo;
		GUndo = NULL;
		
		// Create cache to store component data across rerunning construction scripts
		FComponentInstanceDataCache InstanceDataCache(this);

		// If there are attached objects detach them and store the socket names
		TArray<AActor*> AttachedActors;
		GetAttachedActors(AttachedActors);

		// Struct to store info about attached actors
		struct FAttachedActorInfo
		{
			AActor* AttachedActor;
			FName AttachedToSocket;
		};

		// Save info about attached actors
		TArray<FAttachedActorInfo> AttachedActorInfos;
		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->bCreatedByConstructionScript )
			{
				// Save info about actor to reattach
				FAttachedActorInfo Info;
				Info.AttachedActor = AttachedActor;
				Info.AttachedToSocket = EachRoot->AttachSocketName;
				AttachedActorInfos.Add(Info);

				// Now detach it
				AttachedActor->Modify();
				EachRoot->DetachFromParent(true);					
			}
		}

		// Save off original pose of the actor
		FTransform OldTransform = FTransform::Identity;
		FName  SocketName;
		AActor* Parent = NULL;
		if (RootComponent != NULL)
		{
			// Do not need to detach if root component is not going away
			if(RootComponent->AttachParent != NULL && RootComponent->bCreatedByConstructionScript)
			{
				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;
				}

				SocketName = RootComponent->AttachSocketName;
				//detach it to remove any scaling 
				RootComponent->DetachFromParent(true);
			}
			OldTransform = RootComponent->ComponentToWorld;
		}

		// Destroy existing components
		DestroyConstructedComponents();

		// Reset random streams
		ResetPropertiesForConstruction();

		// Run the construction scripts
		OnConstruction(OldTransform);

		if(Parent)
		{
			USceneComponent* ChildRoot =	GetRootComponent();
//.........这里部分代码省略.........
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:101,代码来源:ActorConstruction.cpp


注:本文中的USceneComponent::DetachFromParent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。