AssetRegistry.GetDependencies
AssetRegistry.GetDependencies
#Overview
name: AssetRegistry.GetDependencies
This variable is created as a Console Variable (cvar).
- type:
Cmd
- help:
<PackageName> //Query the asset registry for dependencies for the specified package
It is referenced in 19
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of AssetRegistry.GetDependencies is to retrieve the dependencies of a specified asset or package from the Unreal Engine Asset Registry system. This function is crucial for understanding and managing asset relationships within the engine.
AssetRegistry.GetDependencies is primarily used by the Asset Management and Content Browser subsystems of Unreal Engine. It’s also utilized by various editor plugins and tools, including:
- Asset Manager Editor
- Reference Viewer
- Asset Reference Restrictions
- Asset Registry Export
- Plugin Reference Viewer
- Asset Renaming and Validation tools
The value of this variable is not set directly, as it’s a function call. The Asset Registry system maintains the dependency information internally, and this function retrieves that data.
This function often interacts with other Asset Registry functions like GetReferencers, and is frequently used in conjunction with asset identification structures like FAssetIdentifier and FAssetData.
Developers should be aware of the following when using this function:
- It can be computationally expensive for large projects, so use it judiciously.
- The function can return different types of dependencies (hard, soft, package, etc.) based on the query flags provided.
- It’s crucial for maintaining asset integrity during operations like renaming, moving, or deleting assets.
Best practices when using AssetRegistry.GetDependencies include:
- Use appropriate query flags to filter the type of dependencies you need.
- Consider caching results if you need to call this function frequently for the same assets.
- Be prepared to handle circular dependencies in your code.
- Use this function in editor-time code rather than runtime code for better performance.
- Always check the return value to ensure the operation was successful before using the retrieved dependencies.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Editor/AssetManagerEditor/Source/AssetManagerEditor/Private/ReferenceViewer/EdGraph_ReferenceViewer.cpp:580
Scope (from outer to inner):
file
function void UEdGraph_ReferenceViewer::GetSortedLinks
Source code excerpt:
else
{
AssetRegistry.GetDependencies(AssetId, LinksToAsset, Query.Categories, Query.Flags);
}
// Sort the links from most important kind of link to least important kind of link, so that if we can't display them all in an ExceedsMaxSearchBreadth test, we
// show the most important links.
Algo::Sort(LinksToAsset, [&CategoryOrder, &IsHard](const FAssetDependency& A, const FAssetDependency& B)
{
#Loc: <Workspace>/Engine/Plugins/Editor/AssetManagerEditor/Source/AssetManagerEditor/Private/ReferenceViewer/EdGraph_ReferenceViewer.cpp:707
Scope (from outer to inner):
file
function void UEdGraph_ReferenceViewer::GetUnfilteredGraphPluginNamesRecursive
Source code excerpt:
else
{
AssetRegistry.GetDependencies(InAssetIdentifier, LinksToAsset);
}
for (const FAssetDependency& Link : LinksToAsset)
{
// Avoid loops by skipping assets we've already visited.
if (OutAssetIdentifiers.Contains(Link.AssetId))
#Loc: <Workspace>/Engine/Plugins/Editor/AssetReferenceRestrictions/Source/AssetReferenceRestrictions/Private/AssetValidator_AssetReferenceRestrictions.cpp:60
Scope (from outer to inner):
file
function EDataValidationResult UAssetValidator_AssetReferenceRestrictions::ValidateLoadedAsset_Implementation
Source code excerpt:
}
AssetRegistry.GetDependencies(PackageFName, SoftDependencies, UE::AssetRegistry::EDependencyCategory::Package, UE::AssetRegistry::EDependencyQuery::Soft | QueryFlags);
for (FName SoftDependency : SoftDependencies)
{
const FString SoftDependencyStr = SoftDependency.ToString();
if (!FPackageName::IsScriptPackage(SoftDependencyStr))
{
TArray<FAssetData> DependencyAssets;
#Loc: <Workspace>/Engine/Plugins/Editor/AssetReferenceRestrictions/Source/AssetReferenceRestrictions/Private/AssetValidator_AssetReferenceRestrictions.cpp:84
Scope (from outer to inner):
file
function EDataValidationResult UAssetValidator_AssetReferenceRestrictions::ValidateLoadedAsset_Implementation
Source code excerpt:
// Now check hard references to cinematic and developers content
TArray<FName> HardDependencies;
AssetRegistry.GetDependencies(PackageFName, HardDependencies, UE::AssetRegistry::EDependencyCategory::Package, UE::AssetRegistry::EDependencyQuery::Hard | QueryFlags);
for (FName HardDependency : HardDependencies)
{
//@TODO: Probably not needed anymore?
#if 0
const FString HardDependencyStr = HardDependency.ToString();
FString UncookedFolderName;
#Loc: <Workspace>/Engine/Plugins/Editor/AssetRegistryExport/Source/Private/AssetRegistryExportCommandlet.cpp:333
Scope (from outer to inner):
file
function int32 UAssetRegistryExportCommandlet::Main
Source code excerpt:
TArray<FAssetIdentifier> PackageDependencies;
AssetRegistry.GetDependencies(FAssetIdentifier(PackageName), PackageDependencies);
for (FAssetIdentifier PackageDependency : PackageDependencies)
{
if (PackageDependency.IsPackage())
{
bool bAlreadyExisted = false;
#Loc: <Workspace>/Engine/Plugins/Experimental/NaniteDisplacedMesh/Source/NaniteDisplacedMeshEditor/Private/GenerateNaniteDisplacedMeshCommandlet.cpp:195
Scope (from outer to inner):
file
function int32 UGenerateNaniteDisplacedMeshCommandlet::Main
Source code excerpt:
{
// Get the dependencies of the level recursively
AssetRegistry.GetDependencies(LevelAsset.PackageName, CurrentDependencies, UE::AssetRegistry::EDependencyCategory::Package, QueryFlags);
while (!CurrentDependencies.IsEmpty())
{
FName DependendPackageName = CurrentDependencies.Pop(EAllowShrinking::No);
if (!StopSearchAt.Contains(DependendPackageName))
{
StopSearchAt.Add(DependendPackageName);
DependenciesToProcess.Add(DependendPackageName);
AssetRegistry.WaitForPackage(DependendPackageName.ToString());
AssetRegistry.GetDependencies(DependendPackageName, CurrentDependencies, UE::AssetRegistry::EDependencyCategory::Package, QueryFlags);
}
}
}
/**
#Loc: <Workspace>/Engine/Plugins/Experimental/NaniteDisplacedMesh/Source/NaniteDisplacedMeshEditor/Private/GenerateNaniteDisplacedMeshCommandlet.cpp:265
Scope (from outer to inner):
file
function int32 UGenerateNaniteDisplacedMeshCommandlet::Main
Source code excerpt:
{
TArray<FName> Dependencies;
AssetRegistry.GetDependencies(LevelReference, Dependencies, UE::AssetRegistry::EDependencyCategory::Package, QueryFlags);
for (const FName& Dependency : Dependencies)
{
// Check if the asset is refered in the original dependencies chain and that it is a level.
if (StopSearchAt.Contains(Dependency) && LevelsName.Contains(Dependency))
{
bHasAddedLevelToDependenciesToProcess = true;
#Loc: <Workspace>/Engine/Plugins/Experimental/PluginReferenceViewer/Source/PluginReferenceViewer/Private/EdGraph_PluginReferenceViewer.cpp:48
Scope (from outer to inner):
file
namespace UE::PluginReferenceViewer::Private
function void FindPluginAssetReferences
Source code excerpt:
AssetDependencies.Empty();
AssetRegistry.GetDependencies(AssetIdentifier, AssetDependencies);
for (const FAssetDependency& AssetDependency : AssetDependencies)
{
AssetDependency.AssetId.PackageName.ToString(AssetPath);
if (AssetPath.StartsWith(ChildMountedAssetPath))
#Loc: <Workspace>/Engine/Source/Developer/AssetTools/Private/AssetRenameManager.cpp:1295
Scope (from outer to inner):
file
function void FAssetRenameManager::SetupPublicAssets
Source code excerpt:
{
TArray<FName> DependencyPackageNames;
AssetRegistry.GetDependencies(Package->GetFName(), DependencyPackageNames);
for (FName DependencyPackageName : DependencyPackageNames)
{
if (OldPackageNameToRenameData.Find(DependencyPackageName))
{
RenamedReferencedPackageNames.Add(DependencyPackageName);
#Loc: <Workspace>/Engine/Source/Developer/AssetTools/Private/AssetTools.cpp:5792
Scope (from outer to inner):
file
function void UAssetToolsImpl::RecursiveGetDependencies
Source code excerpt:
TArray<FName> Dependencies;
IAssetRegistry& AssetRegistry = AssetRegistryModule.Get();
AssetRegistry.GetDependencies(PackageName, Dependencies);
for (TArray<FName>::TConstIterator DependsIt = Dependencies.CreateConstIterator(); DependsIt; ++DependsIt)
{
FString DependencyName = (*DependsIt).ToString();
const bool bIsScriptPackage = DependencyName.StartsWith(TEXT("/Script"));
#Loc: <Workspace>/Engine/Source/Editor/ContentBrowser/Private/FrontendFilters.cpp:91
Scope (from outer to inner):
file
namespace FrontendFilterHelper
function void GetDependencies
Source code excerpt:
const FName PackageName = PackageNamesToProcess.Pop(EAllowShrinking::No);
AssetDependencies.Reset();
AssetRegistry.GetDependencies(FAssetIdentifier(PackageName), AssetDependencies);
for (const FAssetIdentifier& Dependency : AssetDependencies)
{
bool bIsAlreadyInSet = false;
OutDependencySet.Add(Dependency.PackageName, &bIsAlreadyInSet);
if (bIsAlreadyInSet == false)
{
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Commandlets/AssetRegistryGenerator.cpp:1647
Scope (from outer to inner):
file
function void FAssetRegistryGenerator::AddAssetToFileOrderRecursive
Source code excerpt:
TArray<FName> Dependencies;
AssetRegistry.GetDependencies(InPackageName, Dependencies, UE::AssetRegistry::EDependencyCategory::Package, UE::AssetRegistry::EDependencyQuery::Hard);
for (FName DependencyName : Dependencies)
{
if (InPackageNameSet.Contains(DependencyName))
{
if (!InTopLevelAssets.Contains(DependencyName))
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Commandlets/AssetRegistryGenerator.cpp:2056
Scope (from outer to inner):
file
function bool FAssetRegistryGenerator::GetPackageDependencies
Source code excerpt:
bool FAssetRegistryGenerator::GetPackageDependencies(FName PackageName, TArray<FName>& DependentPackageNames, UE::AssetRegistry::EDependencyQuery InDependencyQuery)
{
return AssetRegistry.GetDependencies(PackageName, DependentPackageNames, UE::AssetRegistry::EDependencyCategory::Package, InDependencyQuery);
}
bool FAssetRegistryGenerator::GatherAllPackageDependencies(FName PackageName, TArray<FName>& DependentPackageNames)
{
if (GetPackageDependencies(PackageName, DependentPackageNames, DependencyQuery) == false)
{
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Commandlets/AssetRegistryGenerator.cpp:2632
Scope (from outer to inner):
file
function void FAssetRegistryGenerator::UpdateAssetRegistryData
Source code excerpt:
}
TArray<FAssetDependency> GlobalDependencies;
AssetRegistry.GetDependencies(PackageName, GlobalDependencies, UE::AssetRegistry::EDependencyCategory::All);
State.SetDependencies(FAssetIdentifier(PackageName), GlobalDependencies, UE::AssetRegistry::EDependencyCategory::All);
}
if (OverrideAssetPackageData)
{
// Generated packages pass in their own AssetPackageData
*AssetPackageData = MoveTemp(*OverrideAssetPackageData);
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Commandlets/ContentCommandlets.cpp:393
Scope (from outer to inner):
file
function int32 UResavePackagesCommandlet::InitializeResaveParameters
Source code excerpt:
AssetRegistry.GetReferencers(PackageName, Referencers);
TArray<FName> Dependencies;
AssetRegistry.GetDependencies(PackageName, Dependencies);
for (FName Ref : Referencers)
{
FString File;
FPackageName::SearchForPackageOnDisk(*Ref.ToString(), NULL, &File);
PackageNames.Add(File);
#Loc: <Workspace>/Engine/Source/Runtime/AssetRegistry/Private/AssetRegistryConsoleCommands.h:45
Scope (from outer to inner):
file
function FAssetRegistryConsoleCommands
Source code excerpt:
FConsoleCommandWithArgsDelegate::CreateRaw( this, &FAssetRegistryConsoleCommands::GetByTag ) )
, GetDependenciesCommand(
TEXT( "AssetRegistry.GetDependencies" ),
*LOCTEXT("CommandText_GetDependencies", "<PackageName> //Query the asset registry for dependencies for the specified package").ToString(),
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 ) )
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Sound/SoundWaveLoadingBehavior.cpp:186
Scope (from outer to inner):
file
class class FSoundWaveLoadingBehaviorUtil : public ISoundWaveLoadingBehaviorUtil
function virtual FClassData FindOwningLoadingBehavior
Source code excerpt:
// Query for class references from the Cue instead of loading and opening it.
TArray<FName> SoundCueReferences;
if (!AssetRegistry.GetDependencies(CueAsset.PackageName, SoundCueReferences))
{
UE_LOG(LogAudio, Warning, TEXT("Failed to query SoundCue '%s' for it's dependencies."),
*CueAsset.PackagePath.ToString() );
continue;
}
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AssetManager.cpp:3548
Scope (from outer to inner):
file
function bool UAssetManager::GetManagedPackageList
Source code excerpt:
IAssetRegistry& AssetRegistry = GetAssetRegistry();
AssetRegistry.GetDependencies(PrimaryAssetId, FoundDependencies, UE::AssetRegistry::EDependencyCategory::Manage);
for (const FAssetIdentifier& Identifier : FoundDependencies)
{
if (Identifier.PackageName != NAME_None)
{
bFoundAny = true;
#Loc: <Workspace>/Projects/Lyra/Source/LyraEditor/Validation/EditorValidator_SourceControl.cpp:40
Scope (from outer to inner):
file
function EDataValidationResult UEditorValidator_SourceControl::ValidateLoadedAsset_Implementation
Source code excerpt:
static const FString ScriptPackagePrefix = TEXT("/Script/");
TArray<FName> Dependencies;
AssetRegistry.GetDependencies(PackageFName, Dependencies, UE::AssetRegistry::EDependencyCategory::Package);
for (FName Dependency : Dependencies)
{
const FString DependencyStr = Dependency.ToString();
if (!DependencyStr.StartsWith(ScriptPackagePrefix))
{
FSourceControlStatePtr DependencyState = SourceControlProvider.GetState(SourceControlHelpers::PackageFilename(DependencyStr), EStateCacheUsage::Use);