AssetRegistry.GetReferencers

AssetRegistry.GetReferencers

#Overview

name: AssetRegistry.GetReferencers

This variable is created as a Console Variable (cvar).

It is referenced in 30 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of AssetRegistry.GetReferencers is to retrieve a list of assets that reference a specific asset or package in Unreal Engine’s Asset Registry system.

This function is primarily used by the Asset Management and Editor subsystems of Unreal Engine. It’s particularly relevant for plugins such as AssetManagerEditor, DataValidation, and various Editor tools.

The value of this variable is not set directly, as it’s a function call rather than a variable. It’s invoked when the system needs to find assets that depend on or reference a particular asset.

This function often interacts with other Asset Registry functions like GetDependencies, GetAssetsByPackageName, and various FARFilter operations.

Developers should be aware that:

  1. This function can be computationally expensive for large projects.
  2. It returns both direct and indirect references by default.
  3. The results may include assets that are not currently loaded.

Best practices when using this function include:

  1. Caching results when appropriate to avoid repeated calls.
  2. Using the optional parameters to filter results (e.g., by dependency category or query type).
  3. Being mindful of performance implications in performance-critical sections of code.
  4. Checking the return value to ensure the operation was successful before using the results.

This function is crucial for operations like determining safe deletion of assets, updating references, and analyzing project structure.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Plugins/Animation/DeformerGraph/Source/OptimusEditor/Private/OptimusEditorModule.cpp:127

Scope (from outer to inner):

file
function     void FOptimusEditorModule::PreChange

Source code excerpt:

	// Search for referencing packages to the currently changing user defined struct 
	TArray<FAssetIdentifier> Referencers;
	AssetRegistry.GetReferencers(Changed->GetPackage()->GetFName(), Referencers);
	for (const FAssetIdentifier& Identifier : Referencers)
	{
		TArray<FAssetData> Assets;
		AssetRegistry.GetAssetsByPackageName(Identifier.PackageName, Assets);

		for (const FAssetData& Asset : Assets)

#Loc: <Workspace>/Engine/Plugins/Animation/DeformerGraph/Source/OptimusEditor/Private/OptimusEditorModule.cpp:165

Scope (from outer to inner):

file
function     void FOptimusEditorModule::PostChange

Source code excerpt:

		// Search for referencing packages to the currently changing user defined struct 
		TArray<FAssetIdentifier> Referencers;
		AssetRegistry.GetReferencers(Changed->GetPackage()->GetFName(), Referencers);
		for (const FAssetIdentifier& Identifier : Referencers)
		{
			TArray<FAssetData> Assets;
			AssetRegistry.GetAssetsByPackageName(Identifier.PackageName, Assets);

			for (const FAssetData& Asset : Assets)

#Loc: <Workspace>/Engine/Plugins/Animation/PoseSearch/Source/Runtime/Private/PoseSearchDatabase.cpp:781

Scope (from outer to inner):

file
function     void UPoseSearchDatabase::SynchronizeWithExternalDependencies

Source code excerpt:


	TArray<FAssetIdentifier> Referencers;
	AssetRegistry.GetReferencers(GetPackage()->GetFName(), Referencers);

	TArray<UAnimSequenceBase*> SequencesBase;
	for (const FAssetIdentifier& Referencer : Referencers)
	{
		TArray<FAssetData> Assets;
		AssetRegistry.GetAssetsByPackageName(Referencer.PackageName, Assets);

#Loc: <Workspace>/Engine/Plugins/Editor/AssetManagerEditor/Source/AssetManagerEditor/Private/ReferenceViewer/EdGraph_ReferenceViewer.cpp:537

Scope (from outer to inner):

file
function     void UEdGraph_ReferenceViewer::GetSortedLinks

Source code excerpt:

		if (bReferencers)
		{
			AssetRegistry.GetReferencers(AssetId, LinksToAsset, Query.Categories, Query.Flags);

			if (!Settings->IsShowExternalReferencers())
			{
				TSet<FName> PackageNames;
				for (const FAssetDependency& LinkToAsset : LinksToAsset)
				{

#Loc: <Workspace>/Engine/Plugins/Editor/AssetManagerEditor/Source/AssetManagerEditor/Private/ReferenceViewer/EdGraph_ReferenceViewer.cpp:703

Scope (from outer to inner):

file
function     void UEdGraph_ReferenceViewer::GetUnfilteredGraphPluginNamesRecursive

Source code excerpt:

	if (bReferencers)
	{
		AssetRegistry.GetReferencers(InAssetIdentifier, LinksToAsset);
	}
	else
	{
		AssetRegistry.GetDependencies(InAssetIdentifier, LinksToAsset);
	}
	

#Loc: <Workspace>/Engine/Plugins/Editor/AssetRegistryExport/Source/Private/AssetRegistryExportCommandlet.cpp:126

Scope (from outer to inner):

file
function     int32 UAssetRegistryExportCommandlet::Main

Source code excerpt:

		FString CheckForProjectName = FString("/Script/") + FApp::GetProjectName();
		TArray<FAssetDependency> CheckDeps;
		AssetRegistry.GetReferencers(FAssetIdentifier(*CheckForProjectName), CheckDeps);
		if (CheckDeps.Num() == 0)
		{
			UE_LOG(LogAssetRegistryExport, Error, TEXT("Can't list dependencies without running as a commandlet for the same project that generated the DevelopmentAssetRegistry"));
			return 1;
		}
	}

#Loc: <Workspace>/Engine/Plugins/Editor/DataValidation/Source/DataValidation/Private/EditorValidatorSubsystem.cpp:953

Scope (from outer to inner):

file
function     void UEditorValidatorSubsystem::GatherAssetsToValidateFromChangelist

Source code excerpt:


			TArray<FName> PackageReferencers;
			AssetRegistry.GetReferencers(DeletedPackageName, PackageReferencers, UE::AssetRegistry::EDependencyCategory::Package);
			for (const FName& Referencer : PackageReferencers)
			{
				UE_LOG(LogContentValidation, Log, TEXT("Adding %s to to validated as it is a referencer of deleted asset %s"), *Referencer.ToString(), *DeletedPackageName.ToString());
				TArray<FAssetData> NewAssets;
				AssetRegistry.GetAssetsByPackageName(Referencer, NewAssets, true);
				OutAssets.Append(NewAssets);

#Loc: <Workspace>/Engine/Plugins/Editor/DataValidation/Source/DataValidation/Private/WorldPartitionChangelistValidator.cpp:106

Scope (from outer to inner):

file
function     void UWorldPartitionChangelistValidator::ValidateActorsAndDataLayersFromChangeList

Source code excerpt:

				{
					TArray<FName> ReferencerNames;
					AssetRegistry.GetReferencers(AssetData.PackageName, ReferencerNames, UE::AssetRegistry::EDependencyCategory::All);
		
					FARFilter Filter;
					Filter.bIncludeOnlyOnDiskAssets = true;
					Filter.PackageNames = MoveTemp(ReferencerNames);

					TArray<FAssetData> DataLayerReferencers;

#Loc: <Workspace>/Engine/Plugins/Experimental/NaniteDisplacedMesh/Source/NaniteDisplacedMeshEditor/Private/GenerateNaniteDisplacedMeshCommandlet.cpp:243

Scope (from outer to inner):

file
function     int32 UGenerateNaniteDisplacedMeshCommandlet::Main

Source code excerpt:


				TArray<FName> LevelReferencers;
				AssetRegistry.GetReferencers(LevelAsset.PackageName, LevelReferencers, UE::AssetRegistry::EDependencyCategory::Package, QueryFlags);
				for (const FName& LevelReference : LevelReferencers)
				{
					if (StopSearchAt.Contains(LevelReference))
					{
						DependenciesToProcess.Add(LevelAsset.PackageName);
						StopSearchAt.Add(LevelAsset.PackageName);

#Loc: <Workspace>/Engine/Plugins/FX/Niagara/Source/NiagaraEditor/Private/NiagaraEditorUtilities.cpp:4455

Scope (from outer to inner):

file
function     int FNiagaraEditorUtilities::GetReferencedAssetCount

Source code excerpt:

	SeenObjects.Add(SourceAsset.PackageName);
	TArray<FName> AssetsToCheck;
	AssetRegistry.GetReferencers(SourceAsset.PackageName, AssetsToCheck);
	while (AssetsToCheck.Num() > 0)
	{
		FName AssetPath = AssetsToCheck[0];
		AssetsToCheck.RemoveAtSwap(0);
		if (SeenObjects.Contains(AssetPath))
		{

#Loc: <Workspace>/Engine/Plugins/FX/Niagara/Source/NiagaraEditor/Private/NiagaraEditorUtilities.cpp:4487

Scope (from outer to inner):

file
function     int FNiagaraEditorUtilities::GetReferencedAssetCount

Source code excerpt:

				{
					Count++;
					AssetRegistry.GetReferencers(AssetToCheck.PackageName, AssetsToCheck);
				}
				else
				{
					ensure(Result == ETrackAssetResult::Ignore);
				}
			}

#Loc: <Workspace>/Engine/Source/Developer/AssetTools/Private/AssetTools.cpp:945

Scope (from outer to inner):

file
namespace    UE::AssetTools::Private
function     static void ProcessExcludedDependencies

Source code excerpt:

				for (const FName ExcludedDependency : ExcludedDependencies)
				{
					AssetRegistry.GetReferencers(ExcludedDependency, Referencers);

					for (const FName Reference : Referencers)
					{
						if (PackageToMigrate.Contains(Reference))
						{
							PackageMigrationContext.ExcludedDependencies.Add(ExcludedDependency.ToString());

#Loc: <Workspace>/Engine/Source/Editor/AnimationModifiers/Private/SAnimationModifiersTab.cpp:296

Scope (from outer to inner):

file
function     void SAnimationModifiersTab::FindAnimSequencesForSkeleton

Source code excerpt:

	// Search for referencing packages to the currently open skeleton
	TArray<FAssetIdentifier> Referencers;
	AssetRegistry.GetReferencers(Skeleton->GetOuter()->GetFName(), Referencers);
	for (const FAssetIdentifier& Identifier : Referencers)
	{
		TArray<FAssetData> Assets;
		AssetRegistry.GetAssetsByPackageName(Identifier.PackageName, Assets);

		for (const FAssetData& Asset : Assets)

#Loc: <Workspace>/Engine/Source/Editor/BehaviorTreeEditor/Private/SBehaviorTreeBlackboardView.cpp:292

Scope (from outer to inner):

file
class        class SBehaviorTreeBlackboardItem : public SGraphPaletteItem
function     void LoadReferencerBehaviorTrees

Source code excerpt:


		TArray<FName> ReferencerPackages;
		AssetRegistry.GetReferencers(InBlackboardData.GetOutermost()->GetFName(), ReferencerPackages, UE::AssetRegistry::EDependencyCategory::Package, UE::AssetRegistry::EDependencyQuery::Hard);

		if (ReferencerPackages.Num())
		{
			FScopedSlowTask SlowTask((float)ReferencerPackages.Num(), LOCTEXT("UpdatingBehaviorTrees", "Updating behavior trees"));
			SlowTask.MakeDialog();

#Loc: <Workspace>/Engine/Source/Editor/LevelInstanceEditor/Private/PackedLevelActorUtils.cpp:36

Scope (from outer to inner):

file
function     void FPackedLevelActorUtils::GetPackedBlueprintsForWorldAsset

Source code excerpt:


		TArray<FName> ReferencerPackages;
		AssetRegistry.GetReferencers(*ProcessingAsset.GetLongPackageName(), ReferencerPackages);

		for (FName ReferencerPackage : ReferencerPackages)
		{
			TArray<FAssetData> Assets;
			AssetRegistry.GetAssetsByPackageName(ReferencerPackage, Assets);

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Commandlets/AssetRegistryGenerator.cpp:1919

Scope (from outer to inner):

file
function     bool FAssetRegistryGenerator::WriteCookerOpenOrder

Source code excerpt:

		{
			TArray<FName> Referencers;
			AssetRegistry.GetReferencers(PackageName, Referencers, UE::AssetRegistry::EDependencyCategory::Package, UE::AssetRegistry::EDependencyQuery::Hard);

			bool bIsTopLevel = true;
			bool bIsMap = MapList.Contains(PackageName);

			if (!bIsMap && Referencers.Num() > 0)
			{

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Commandlets/ContentCommandlets.cpp:391

Scope (from outer to inner):

file
function     int32 UResavePackagesCommandlet::InitializeResaveParameters

Source code excerpt:


		TArray<FName> Referencers;
		AssetRegistry.GetReferencers(PackageName, Referencers);
		TArray<FName> Dependencies;
		AssetRegistry.GetDependencies(PackageName, Dependencies);

		for (FName Ref : Referencers)
		{
			FString File;

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Commandlets/ContentCommandlets.cpp:428

Scope (from outer to inner):

file
function     int32 UResavePackagesCommandlet::InitializeResaveParameters

Source code excerpt:

			{
				TArray<FName> Referencers;
				AssetRegistry.GetReferencers(AssetData.PackageName, Referencers);

				// For external objects referencers, also add the object's outer package as a referencer so it can be handled by PerformAdditionalOperations.
				FARFilter Filter;
				Filter.bIncludeOnlyOnDiskAssets = true;
				Filter.PackageNames = Referencers;

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Commandlets/ContentCommandlets.cpp:1426

Scope (from outer to inner):

file
function     int32 UResavePackagesCommandlet::Main

Source code excerpt:

		TArray<FName> Referencers;

		AssetRegistry.GetReferencers(PackageName, Referencers);

		if (Referencers.Num() > 0)
		{
			if (Verbosity != ONLY_ERRORS)
			{
				UE_LOG(LogContentCommandlet, Display, TEXT("Can't delete redirector [%s], unsaved packages reference it"), *Filename);

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Commandlets/SwapSoundForDialogueInCuesCommandlet.cpp:92

Scope (from outer to inner):

file
function     int32 USwapSoundForDialogueInCuesCommandlet::Main

Source code excerpt:

			// Find referencers of the context's sound wave.
			TArray<FName> SoundWaveReferencerNames;
			if (!AssetRegistry.GetReferencers(SoundWavePackage->GetFName(), SoundWaveReferencerNames))
			{
				UE_LOG(LogSwapSoundForDialogueInCuesCommandlet, Error, TEXT("Asset registry found dialogue wave (%s) with a context referencing sound wave (%s) but failed to search for referencers of the sound wave."), *AssetData.AssetName.ToString(), *SoundWave->GetName());
				continue;
			}

			// Skip further searching if there are no sound wave referencers.

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Cooker/ExternalCookOnTheFlyServer.cpp:124

Scope (from outer to inner):

file
function     void FExternalCookOnTheFlyServer::AssetUpdatedOnDisk

Source code excerpt:

		FName ModifiedPackage = ModifiedPackagesToRecurse.Pop(EAllowShrinking::No);
		TArray<FName> Referencers;
		AssetRegistry.GetReferencers(ModifiedPackage, Referencers, UE::AssetRegistry::EDependencyCategory::Package, UE::AssetRegistry::EDependencyQuery::Hard);
		for (FName Referencer : Referencers)
		{
			if (!AllPackagesToRecook.Contains(Referencer))
			{
				ModifiedPackagesToRecurse.Push(Referencer);
				AllPackagesToRecook.Add(Referencer);

#Loc: <Workspace>/Engine/Source/Runtime/AssetRegistry/Private/AssetRegistryConsoleCommands.h:49

Scope: file

Source code excerpt:

		FConsoleCommandWithArgsDelegate::CreateRaw( this, &FAssetRegistryConsoleCommands::GetDependencies ) )
	,	GetReferencersCommand(
		TEXT( "AssetRegistry.GetReferencers" ),
		*LOCTEXT("CommandText_GetReferencers", "<ObjectPath> //Query the asset registry for referencers for the specified package").ToString(),
		FConsoleCommandWithArgsDelegate::CreateRaw( this, &FAssetRegistryConsoleCommands::GetReferencers ) )
	,	FindInvalidUAssetsCommand(
		TEXT( "AssetRegistry.Debug.FindInvalidUAssets" ),
		*LOCTEXT("CommandText_FindInvalidUAssets", "Finds a list of all assets which are in UAsset files but do not share the name of the package").ToString(),
		FConsoleCommandWithArgsDelegate::CreateRaw( this, &FAssetRegistryConsoleCommands::FindInvalidUAssets ) )

#Loc: <Workspace>/Engine/Source/Runtime/AssetRegistry/Private/AssetRegistryHelpers.cpp:129

Scope (from outer to inner):

file
function     void UAssetRegistryHelpers::FindReferencersOfAssetOfClass

Source code excerpt:


	TArray<FAssetIdentifier> Referencers;
	AssetRegistry.GetReferencers(InAssetIdentifier, Referencers);

	for (auto AssetIdentifier : Referencers)
	{
		TArray<FAssetData> Assets;
		AssetRegistry.GetAssetsByPackageName(AssetIdentifier.PackageName, Assets);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Sound/SoundWaveLoadingBehavior.cpp:144

Scope (from outer to inner):

file
class        class FSoundWaveLoadingBehaviorUtil : public ISoundWaveLoadingBehaviorUtil
function     virtual FClassData FindOwningLoadingBehavior

Source code excerpt:


		TArray<FName> SoundWaveReferencerNames;
		if (!AssetRegistry.GetReferencers(WavePackage->GetFName(), SoundWaveReferencerNames))
		{
			return {};
		}

		if (SoundWaveReferencerNames.IsEmpty())
		{

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AssetManager.cpp:3234

Scope (from outer to inner):

file
function     void UAssetManager::DumpReferencersForPackage

Source code excerpt:

		TArray<FAssetIdentifier> FoundReferencers;

		AssetRegistry.GetReferencers(FName(*PackageString), FoundReferencers, UE::AssetRegistry::EDependencyCategory::Package);

		for (const FAssetIdentifier& Identifier : FoundReferencers)
		{
			FString ReferenceString = Identifier.ToString();

			ReportLines.Add(FString::Printf(TEXT("\t\"%s\" -> \"%s\";"), *ReferenceString, *PackageString));

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AssetManager.cpp:3268

Scope (from outer to inner):

file
function     void UAssetManager::GetAllReferencersForPackage

Source code excerpt:

			FARFilter Filter;
			Filter.bIncludeOnlyOnDiskAssets = true;
			AssetRegistry.GetReferencers(PackageName, Filter.PackageNames, UE::AssetRegistry::EDependencyCategory::Package);

			TArray<FAssetData> AssetReferencers;
			AssetRegistry.GetAssets(Filter, AssetReferencers);
			OutFoundAssets.Append(AssetReferencers);
			for (const FAssetData& AssetData : AssetReferencers)
			{

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AssetManager.cpp:3585

Scope (from outer to inner):

file
function     bool UAssetManager::GetPackageManagers

Source code excerpt:

	ReferencingPrimaryAssets.Reserve(128);

	AssetRegistry.GetReferencers(PackageName, ReferencingPrimaryAssets, UE::AssetRegistry::EDependencyCategory::Manage);

	for (int32 IdentifierIndex = 0; IdentifierIndex < ReferencingPrimaryAssets.Num(); IdentifierIndex++)
	{
		FAssetDependency& AssetDependency = ReferencingPrimaryAssets[IdentifierIndex];
		FPrimaryAssetId PrimaryAssetId = AssetDependency.AssetId.GetPrimaryAssetId();
		if (!PrimaryAssetId.IsValid())

#Loc: <Workspace>/Projects/Lyra/Source/LyraEditor/Validation/EditorValidator.cpp:170

Scope (from outer to inner):

file
function     bool UEditorValidator::ValidatePackages

Source code excerpt:

		UE_LOG(LogLyraEditor, Display, TEXT("Adding referencers for deleted package %s to be verified"), *DeletedPackageName);
		TArray<FName> PackageReferencers;
		AssetRegistry.GetReferencers(FName(*DeletedPackageName), PackageReferencers, UE::AssetRegistry::EDependencyCategory::Package);
		for (const FName& Referencer : PackageReferencers)
		{
			const FString ReferencerString = Referencer.ToString();
			if (!DeletedPackageNames.Contains(ReferencerString) && !IsInUncookedFolder(ReferencerString))
			{
				UE_LOG(LogLyraEditor, Display, TEXT("    Deleted package referencer %s was added to the queue to be verified"), *ReferencerString);

#Loc: <Workspace>/Projects/Lyra/Source/LyraEditor/Validation/EditorValidator_Blueprints.cpp:48

Scope (from outer to inner):

file
function     EDataValidationResult UEditorValidator_Blueprints::ValidateLoadedAsset_Implementation

Source code excerpt:

				{
					TArray<FName> HardReferencers;
					AssetRegistry.GetReferencers(PackageToProcess, HardReferencers, UE::AssetRegistry::EDependencyCategory::Package, UE::AssetRegistry::EDependencyQuery::Hard);
					for (FName HardReferencer : HardReferencers)
					{
						if (!AllHardReferencers.Contains(HardReferencer))
						{
							AllHardReferencers.Add(HardReferencer);
							TArray<FAssetData> RefAssets;

#Loc: <Workspace>/Projects/Lyra/Source/LyraEditor/Validation/EditorValidator_MaterialFunctions.cpp:45

Scope (from outer to inner):

file
function     EDataValidationResult UEditorValidator_MaterialFunctions::ValidateLoadedAsset_Implementation

Source code excerpt:

			{
				TArray<FName> HardReferencers;
				AssetRegistry.GetReferencers(PackageToProcess, HardReferencers, UE::AssetRegistry::EDependencyCategory::Package, UE::AssetRegistry::EDependencyQuery::Hard);
				for (FName HardReferencer : HardReferencers)
				{
					if (!AllHardReferencers.Contains(HardReferencer))
					{
						AllHardReferencers.Add(HardReferencer);
						TArray<FAssetData> RefAssets;