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


C++ UPackage::IsFullyLoaded方法代码示例

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


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

示例1: LoadSecondaryLevels

void UWorld::LoadSecondaryLevels(bool bForce, TSet<FString>* CookedPackages)
{
	check( GIsEditor );

	// streamingServer
	// Only load secondary levels in the Editor, and not for commandlets.
	if( (!IsRunningCommandlet() || bForce)
	// Don't do any work for world info actors that are part of secondary levels being streamed in! 
	&& !IsAsyncLoading())
	{
		for( int32 LevelIndex=0; LevelIndex<StreamingLevels.Num(); LevelIndex++ )
		{
			ULevelStreaming* const StreamingLevel = StreamingLevels[LevelIndex];
			if( StreamingLevel )
			{
				bool bAlreadyCooked = false;
				// If we are cooking don't cook sub levels multiple times if they've already been cooked
				FString PackageFilename;
				const FString StreamingLevelWorldAssetPackageName = StreamingLevel->GetWorldAssetPackageName();
				if (CookedPackages)
				{
					if (FPackageName::DoesPackageExist(StreamingLevelWorldAssetPackageName, NULL, &PackageFilename))
					{
						PackageFilename = FPaths::ConvertRelativePathToFull(PackageFilename);
						bAlreadyCooked |= CookedPackages->Contains( PackageFilename );
					}
				}


				bool bAlreadyLoaded = false;
				UPackage* LevelPackage = FindObject<UPackage>(NULL, *StreamingLevelWorldAssetPackageName,true);
				// don't need to do any extra work if the level is already loaded
				if ( LevelPackage && LevelPackage->IsFullyLoaded() ) 
				{
					bAlreadyLoaded = true;
				}

				if ( !bAlreadyCooked && !bAlreadyLoaded )
				{
					bool bLoadedLevelPackage = false;
					const FName StreamingLevelWorldAssetPackageFName = StreamingLevel->GetWorldAssetPackageFName();
					// Load the package and find the world object.
					if( FPackageName::IsShortPackageName(StreamingLevelWorldAssetPackageFName) == false )
					{
						ULevel::StreamedLevelsOwningWorld.Add(StreamingLevelWorldAssetPackageFName, this);
						LevelPackage = LoadPackage( NULL, *StreamingLevelWorldAssetPackageName, LOAD_None );
						ULevel::StreamedLevelsOwningWorld.Remove(StreamingLevelWorldAssetPackageFName);

						if( LevelPackage )
						{
							bLoadedLevelPackage = true;

							// Find the world object in the loaded package.
							UWorld* LoadedWorld	= UWorld::FindWorldInPackage(LevelPackage);
							// If the world was not found, it could be a redirector to a world. If so, follow it to the destination world.
							if (!LoadedWorld)
							{
								LoadedWorld = UWorld::FollowWorldRedirectorInPackage(LevelPackage);
							}
							check(LoadedWorld);

							if ( !LevelPackage->IsFullyLoaded() )
							{
								// LoadedWorld won't be serialized as there's a BeginLoad on the stack so we manually serialize it here.
								check( LoadedWorld->GetLinker() );
								LoadedWorld->GetLinker()->Preload( LoadedWorld );
							}


							// Keep reference to prevent garbage collection.
							check( LoadedWorld->PersistentLevel );

							ULevel* NewLoadedLevel = LoadedWorld->PersistentLevel;
							NewLoadedLevel->OwningWorld = this;

							StreamingLevel->SetLoadedLevel(NewLoadedLevel);
						}
					}
					else
					{
						UE_LOG(LogSpawn, Warning, TEXT("Streaming level uses short package name (%s). Level will not be loaded."), *StreamingLevelWorldAssetPackageName);
					}

					// Remove this level object if the file couldn't be found.
					if ( !bLoadedLevelPackage )
					{		
						StreamingLevels.RemoveAt( LevelIndex-- );
						MarkPackageDirty();
					}
				}
			}
		}
	}
}
开发者ID:magetron,项目名称:UnrealEngine4-mod,代码行数:94,代码来源:LevelActor.cpp


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