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


C++ UMovieScene::GetSpawnable方法代码示例

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


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

示例1: SpawnActorsForMovie

void UActorAnimationPlayer::SpawnActorsForMovie(TSharedRef<FMovieSceneSequenceInstance> MovieSceneInstance)
{
	UWorld* WorldPtr = World.Get();

	if (WorldPtr == nullptr)
	{
		return;
	}

	UMovieScene* MovieScene = MovieSceneInstance->GetSequence()->GetMovieScene();

	if (MovieScene == nullptr)
	{
		return;
	}

	TArray<FSpawnedActorInfo>* FoundSpawnedActors = InstanceToSpawnedActorMap.Find(MovieSceneInstance);

	if (FoundSpawnedActors != nullptr)
	{
		// Remove existing spawned actors for this movie
		DestroyActorsForMovie( MovieSceneInstance );
	}

	TArray<FSpawnedActorInfo>& SpawnedActorList = InstanceToSpawnedActorMap.Add(MovieSceneInstance, TArray<FSpawnedActorInfo>());

	for (auto SpawnableIndex = 0; SpawnableIndex < MovieScene->GetSpawnableCount(); ++SpawnableIndex)
	{
		auto& Spawnable = MovieScene->GetSpawnable(SpawnableIndex);
		UClass* GeneratedClass = Spawnable.GetClass();
		
		if ((GeneratedClass == nullptr) || !GeneratedClass->IsChildOf(AActor::StaticClass()))
		{
			continue;
		}

		AActor* ActorCDO = CastChecked<AActor>(GeneratedClass->ClassDefaultObject);
		const FVector SpawnLocation = ActorCDO->GetRootComponent()->RelativeLocation;
		const FRotator SpawnRotation = ActorCDO->GetRootComponent()->RelativeRotation;

		FActorSpawnParameters SpawnInfo;
		{
			SpawnInfo.ObjectFlags = RF_NoFlags;
		}

		AActor* NewActor = WorldPtr->SpawnActor(GeneratedClass, &SpawnLocation, &SpawnRotation, SpawnInfo);

		if (NewActor)
		{	
			// Actor was spawned OK!
			FSpawnedActorInfo NewInfo;
			{
				NewInfo.RuntimeGuid = Spawnable.GetGuid();
				NewInfo.SpawnedActor = NewActor;
			}
						
			SpawnedActorList.Add(NewInfo);
		}
	}
}
开发者ID:frobro98,项目名称:UnrealSource,代码行数:60,代码来源:ActorAnimationPlayer.cpp

示例2: SpawnActorsForMovie

void URuntimeMovieScenePlayer::SpawnActorsForMovie( TSharedRef<FMovieSceneInstance> MovieSceneInstance  )
{
	UWorld* WorldPtr = World.Get();
	if( WorldPtr != NULL && MovieSceneBindings != NULL )
	{
		UMovieScene* MovieScene = MovieSceneInstance->GetMovieScene();
		if( MovieScene != NULL )
		{
			TArray<FSpawnedActorInfo>* FoundSpawnedActors = InstanceToSpawnedActorMap.Find( MovieSceneInstance );
			if( FoundSpawnedActors )
			{
				// Remove existing spawned actors for this movie
				DestroyActorsForMovie( MovieSceneInstance );
			}

			TArray<FSpawnedActorInfo>& SpawnedActorList = InstanceToSpawnedActorMap.Add( MovieSceneInstance, TArray<FSpawnedActorInfo>() );

			for( auto SpawnableIndex = 0; SpawnableIndex < MovieScene->GetSpawnableCount(); ++SpawnableIndex )
			{
				auto& Spawnable = MovieScene->GetSpawnable( SpawnableIndex );

				UClass* GeneratedClass = Spawnable.GetClass();
				if ( GeneratedClass != NULL )
				{
					const bool bIsActorBlueprint = GeneratedClass->IsChildOf( AActor::StaticClass() );
					if ( bIsActorBlueprint )
					{
						AActor* ActorCDO = CastChecked< AActor >( GeneratedClass->ClassDefaultObject );

						const FVector SpawnLocation = ActorCDO->GetRootComponent()->RelativeLocation;
						const FRotator SpawnRotation = ActorCDO->GetRootComponent()->RelativeRotation;

						FActorSpawnParameters SpawnInfo;
						SpawnInfo.ObjectFlags = RF_NoFlags;
						AActor* NewActor = WorldPtr->SpawnActor( GeneratedClass, &SpawnLocation, &SpawnRotation, SpawnInfo );
						if( NewActor )
						{	
							// Actor was spawned OK!
							FSpawnedActorInfo NewInfo;
							NewInfo.RuntimeGuid = Spawnable.GetGuid();
							NewInfo.SpawnedActor = NewActor;
						
							SpawnedActorList.Add( NewInfo );
						}
					}
				}
			}
		}
	}
}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:50,代码来源:RuntimeMovieScenePlayer.cpp

示例3: SpawnOrDestroyObjectsForInstance

void FSequencerActorBindingManager::SpawnOrDestroyObjectsForInstance( TSharedRef<FMovieSceneInstance> MovieSceneInstance, const bool bDestroyAll )
{
	bool bAnyLevelActorsChanged = false;

	// Get the list of puppet objects for the movie scene
	TArray< TSharedRef<FPuppetActorInfo> >& PuppetObjects = InstanceToPuppetObjectsMap.FindOrAdd( MovieSceneInstance );

	UMovieScene* MovieScene = MovieSceneInstance->GetMovieScene();

	// Remove any puppet objects that we no longer need
	{
		for( auto PuppetObjectIndex = 0; PuppetObjectIndex < PuppetObjects.Num(); ++PuppetObjectIndex )
		{
			if( PuppetObjects[ PuppetObjectIndex ]->GetType() == EPuppetObjectType::Actor )
			{
				TSharedRef< FPuppetActorInfo > PuppetActorInfo = StaticCastSharedRef< FPuppetActorInfo >( PuppetObjects[ PuppetObjectIndex ] );

				// Figure out if we still need this puppet actor
				bool bShouldDestroyActor = true;
				if( !bDestroyAll )
				{
					for( auto SpawnableIndex = 0; SpawnableIndex < MovieScene->GetSpawnableCount(); ++SpawnableIndex )
					{
						auto& Spawnable = MovieScene->GetSpawnable( SpawnableIndex );
						if( Spawnable.GetGuid() == PuppetActorInfo->SpawnableGuid )
						{
							bShouldDestroyActor = false;
							break;
						}
					}
				}

				if( bShouldDestroyActor )
				{
					AActor* PuppetActor = PuppetActorInfo->PuppetActor.Get();
					if( PuppetActor != NULL )
					{
						UWorld* PuppetWorld = PuppetActor->GetWorld();
						if( ensure( PuppetWorld != NULL ) )
						{
							// Destroy this actor
							{
								// Ignored unless called while game is running
								const bool bNetForce = false;

								// We don't want to dirty the level for puppet actor changes
								const bool bShouldModifyLevel = false;

								if( !bAnyLevelActorsChanged )
								{
									DeselectAllPuppetObjects();
								}

								// Actor should never be selected in the editor at this point.  We took care of that up above.
								ensure( !PuppetActor->IsSelected() );

								const bool bWasDestroyed = PuppetWorld->DestroyActor( PuppetActor, bNetForce, bShouldModifyLevel );

								if( bWasDestroyed )
								{
									bAnyLevelActorsChanged = true;
									PuppetObjects.RemoveAt( PuppetObjectIndex-- );
								}
								else
								{
									// @todo sequencer: At least one puppet couldn't be cleaned up!
								}
							}
						}
					}
					else
					{
						// Actor is no longer valid (probably the world was destroyed)
					}
				}
			}
			else
			{
				check(0);	// Unhandled type
			}
		}
	}

	if( !bDestroyAll )
	{
		for( auto SpawnableIndex = 0; SpawnableIndex < MovieScene->GetSpawnableCount(); ++SpawnableIndex )
		{
			FMovieSceneSpawnable& Spawnable = MovieScene->GetSpawnable( SpawnableIndex );

			// Must have a valid world for us to be able to do this
			if( ActorWorld != NULL )
			{
				// Do we already have a puppet for this spawnable?
				bool bIsAlreadySpawned = false;
				for( auto PuppetIndex = 0; PuppetIndex < PuppetObjects.Num(); ++PuppetIndex )
				{
					auto& PuppetObject = PuppetObjects[ PuppetIndex ];
					if( PuppetObject->SpawnableGuid == Spawnable.GetGuid() )
					{
						bIsAlreadySpawned = true;
//.........这里部分代码省略.........
开发者ID:didixp,项目名称:Ark-Dev-Kit,代码行数:101,代码来源:SequencerActorBindingManager.cpp


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