虚幻4 加载蓝图过程(2)——读取文件过程

读取文件过程

/UnrealEngine/Engine/Source/Runtime/CoreUObject/Private/UObject/LinkerLoad.cpp


/**
 * Ticks an in-flight linker and spends InTimeLimit seconds on creation. This is a soft time limit used
 * if bInUseTimeLimit is true.
 *
 * @param	InTimeLimit		Soft time limit to use if bInUseTimeLimit is true
 * @param	bInUseTimeLimit	Whether to use a (soft) timelimit
 * @param	bInUseFullTimeLimit	Whether to use the entire time limit, even if blocked on I/O
 * 
 * @return	true if linker has finished creation, false if it is still in flight
 */
FLinkerLoad::ELinkerStatus FLinkerLoad::Tick( float InTimeLimit, bool bInUseTimeLimit, bool bInUseFullTimeLimit )
{
	ELinkerStatus Status = LINKER_Loaded;

	if( bHasFinishedInitialization == false )
	{
		// Store variables used by functions below.
		TickStartTime		= FPlatformTime::Seconds();
		bTimeLimitExceeded	= false;
		bUseTimeLimit		= bInUseTimeLimit;
		bUseFullTimeLimit	= bInUseFullTimeLimit;
		TimeLimit			= InTimeLimit;

		do
		{
			bool bCanSerializePackageFileSummary = false;
			if (GEventDrivenLoaderEnabled)
			{
				check(Loader || bDynamicClassLinker);
				bCanSerializePackageFileSummary = true;
			}
			else
			{
				// Create loader, aka FArchive used for serialization and also precache the package file summary.
				// false is returned until any precaching is complete.
				SCOPED_LOADTIMER(LinkerLoad_CreateLoader);
				Status = CreateLoader(TFunction([]() {}));

				bCanSerializePackageFileSummary = (Status == LINKER_Loaded);
			}

			// Serialize the package file summary and presize the various arrays (name, import & export map)
			if (bCanSerializePackageFileSummary)
			{
				SCOPED_LOADTIMER(LinkerLoad_SerializePackageFileSummary);
				Status = SerializePackageFileSummary();
			}

			// Serialize the name map and register the names.
			if( Status == LINKER_Loaded )
			{
				SCOPED_LOADTIMER(LinkerLoad_SerializeNameMap);
				Status = SerializeNameMap();
			}

			// Serialize the gatherable text data map.
			if( Status == LINKER_Loaded )
			{
				SCOPED_LOADTIMER(LinkerLoad_SerializeGatherableTextDataMap);
				Status = SerializeGatherableTextDataMap();
			}

			// Serialize the import map.
			if( Status == LINKER_Loaded )
			{
				SCOPED_LOADTIMER(LinkerLoad_SerializeImportMap);
				Status = SerializeImportMap();
			}

			// Serialize the export map.
			if( Status == LINKER_Loaded )
			{
				SCOPED_LOADTIMER(LinkerLoad_SerializeExportMap);
				Status = SerializeExportMap();
			}

			// Fix up import map for backward compatible serialization.
			if( Status == LINKER_Loaded )
			{	
				SCOPED_LOADTIMER(LinkerLoad_FixupImportMap);
				Status = FixupImportMap();
			}

			// Fix up export map for object class conversion 
			if( Status == LINKER_Loaded )
			{	
				SCOPED_LOADTIMER(LinkerLoad_FixupExportMap);
				Status = FixupExportMap();
			}

			// Serialize the dependency map.
			if( Status == LINKER_Loaded )
			{
				SCOPED_LOADTIMER(LinkerLoad_SerializeDependsMap);
				Status = SerializeDependsMap();
			}

			// Hash exports.
			if( Status == LINKER_Loaded )
			{
				SCOPED_LOADTIMER(LinkerLoad_CreateExportHash);
				Status = CreateExportHash();
			}

			// Find existing objects matching exports and associate them with this linker.
			if( Status == LINKER_Loaded )
			{
				SCOPED_LOADTIMER(LinkerLoad_FindExistingExports);
				Status = FindExistingExports();
			}

			if (Status == LINKER_Loaded)
			{
				SCOPED_LOADTIMER(LinkerLoad_SerializePreloadDependencies);
				Status = SerializePreloadDependencies();
			}

			// Finalize creation process.
			if( Status == LINKER_Loaded )
			{
				SCOPED_LOADTIMER(LinkerLoad_FinalizeCreation);
				Status = FinalizeCreation();
			}
		}
		// Loop till we are done if no time limit is specified, or loop until the real time limit is up if we want to use full time
		while (Status == LINKER_TimedOut && 
			(!bUseTimeLimit || (bUseFullTimeLimit && !IsTimeLimitExceeded(TEXT("Checking Full Timer"))))
			);
	}

	if (Status == LINKER_Failed)
	{
		LinkerRoot->LinkerLoad = nullptr;
#if WITH_EDITOR

		delete LoadProgressScope;
		LoadProgressScope = nullptr;	
#endif
	}

	// Return whether we completed or not.
	return Status;
}


你可能感兴趣的:(虚幻4 加载蓝图过程(2)——读取文件过程)