Unreal/CarlaUE4/Plugins/RoadRunnerImporter/Source/RoadRunnerImporter/Private/RoadRunnerImportUtil.cpp
////////////////////////////////////////////////////////////////////////////////
// Fix up all object redirectors in the project
Fix up all object redirectors in the project
Fix up all object redirectors in the project
void FRoadRunnerImportUtil::FixUpRedirectors()
{
	FAssetRegistryModule& AssetRegistryModule = FModuleManager::Get().LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
	FARFilter filter;
	filter.bRecursivePaths = true;
	filter.PackagePaths.Emplace("/Game");
	filter.ClassNames.Emplace(TEXT("ObjectRedirector"));
	TArray<FAssetData> assetList;
	AssetRegistryModule.Get().GetAssets(filter, assetList);
	if (assetList.Num() > 0)
	{
		TArray<UObjectRedirector*> redirectors;
		for (const auto& asset : assetList)
		{
			UE_LOG(RoadRunnerImporter, Log, TEXT("Cleaning up redirector: %s"), *asset.PackageName.ToString());
			UPackage* pkg = PackageTools::LoadPackage(asset.PackageName.ToString());
			UObjectRedirector* redirector = LoadObject<UObjectRedirector>(pkg, *asset.AssetName.ToString());
			if(redirector)
				redirectors.Add(redirector);
		}
		FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked<FAssetToolsModule>(TEXT("AssetTools"));
		AssetToolsModule.Get().FixupReferencers(redirectors);
	}
}
void FRoadRunnerImportUtil :: FixUpRedirectors ( ) { FAssetRegistryModule & AssetRegistryModule = FModuleManager :: Get ( ) . LoadModuleChecked < FAssetRegistryModule > ( TEXT ( " " ) ) ; FARFilter filter ; filter . bRecursivePaths = true ; filter . PackagePaths . Emplace ( " " ) ; filter . ClassNames . Emplace ( TEXT ( " " ) ) ; TArray < FAssetData > assetList ; AssetRegistryModule . Get ( ) . GetAssets ( filter , assetList ) ; if ( assetList . Num ( ) > 0 ) { TArray < UObjectRedirector * > redirectors ; for ( const auto & asset : assetList ) { UE_LOG ( RoadRunnerImporter , Log , TEXT ( " " ) , * asset . PackageName . ToString ( ) ) ; UPackage * pkg = PackageTools :: LoadPackage ( asset . PackageName . ToString ( ) ) ; UObjectRedirector * redirector = LoadObject < UObjectRedirector > ( pkg , * asset . AssetName . ToString ( ) ) ; if ( redirector ) redirectors . Add ( redirector ) ; } FAssetToolsModule & AssetToolsModule = FModuleManager :: LoadModuleChecked < FAssetToolsModule > ( TEXT ( " " ) ) ; AssetToolsModule . Get ( ) . FixupReferencers ( redirectors ) ; } }
Fix up all object redirectors in the project
Fix up all object redirectors in the project
// Form a filter from the paths // Query for a list of assets in the selected paths // Load the asset tools module