# How do i check assets for references?

**URL:** <https://forums.unrealengine.com/t/how-do-i-check-assets-for-references/468804>\
**Category:** Editor Scripting\
**Tags:** dependencies, reference, references, unreal-engine, question\
**Created:** [July 29, 2020, 12:04am UTC](https://forums.unrealengine.com/t/how-do-i-check-assets-for-references/468804 "2020-07-29T00:04:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![B0btimus](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@B0btimus](https://forums.unrealengine.com/u/B0btimus)\
**Post date:** [July 29, 2020, 12:04am UTC](https://forums.unrealengine.com/t/how-do-i-check-assets-for-references/468804/1 "2020-07-29T00:04:22Z")

</div>

Hi,  
i want to check the assets for references but all referencers/dependencies are always zero. Can anyone help, please?  
Here is my code:

void FCleanUp\_PluginModule::SearchForAssets()  
{  
UE\_LOG(LogTemp, Warning, TEXT(“Searching For Assets”));

```
//path to search
const FString DirectoryFolder = FPaths::ProjectContentDir();
//set FileExtension to NULL to get all files with any extension
const FString FileExtension = "";
//array to store found files
TArray<FString> FoundFiles;
//find files in contentbrowser
FPlatformFileManager::Get().GetPlatformFile().FindFiles(FoundFiles, *DirectoryFolder, *FileExtension);

FAssetRegistryModule& AssetRegistryModule = FModuleManager::GetModuleChecked<FAssetRegistryModule>("AssetRegistry");

for (int i = 0; i < FoundFiles.Num(); i++)
{
	//check for dependencies
	TArray<FName> HardDependencies;
	AssetRegistryModule.Get().GetDependencies(*FoundFiles[i], HardDependencies,EAssetRegistryDependencyType::Hard);

	TArray<FName> SoftDependencies;
	AssetRegistryModule.Get().GetDependencies(*FoundFiles[i], SoftDependencies,EAssetRegistryDependencyType::Soft);

	if (HardDependencies.Num() > 0)
	{
		UE_LOG(LogTemp, Warning, TEXT("hard dependencies found for %s"), *FoundFiles[i]);
	}
	if (SoftDependencies.Num() > 0)
	{
		UE_LOG(LogTemp, Warning, TEXT("soft dependencies found for %s"), *FoundFiles[i]);
	}
	//check for references
	TArray<FName> HardReferecers;
	AssetRegistryModule.Get().GetReferencers(*FoundFiles[i], HardReferecers,EAssetRegistryDependencyType::Hard);

	TArray<FName> SoftReferencers;
	AssetRegistryModule.Get().GetReferencers(*FoundFiles[i], SoftReferencers,EAssetRegistryDependencyType::Soft);

	if (HardReferecers.Num() > 0)
	{
		UE_LOG(LogTemp, Warning, TEXT("hard reference found for %s"), *FoundFiles[i]);
	}
	if (SoftReferencers.Num() > 0)
	{
		UE_LOG(LogTemp, Warning, TEXT("soft reference found for %s"), *FoundFiles[i]);
	}
}

```

}

---

<div class="post-metadata">

**Author:** ![SantKadog](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SantKadog](https://forums.unrealengine.com/u/SantKadog)\
**Post date:** [April 27, 2021, 5:28pm UTC](https://forums.unrealengine.com/t/how-do-i-check-assets-for-references/468804/2 "2021-04-27T17:28:53Z")

</div>

For those who are still looking for an answer to that old but still valid question.

In AssetDataGatherer there is a flag that controls whether the dependencies must be gathered :

```
bGatherDependsData = (GIsEditor && !FParse::Param( FCommandLine::Get(), TEXT("NoDependsGathering") )) || FParse::Param(FCommandLine::Get(),TEXT("ForceDependsGathering")); 
```

if you are outside of the editor, adding the extra -ForceDependsGathering on the command line will do the trick.

---

<div class="post-metadata">

**Author:** ![dneg\_cleu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dneg\_cleu](https://forums.unrealengine.com/u/dneg_cleu)\
**Post date:** [March 16, 2022, 9:41pm UTC](https://forums.unrealengine.com/t/how-do-i-check-assets-for-references/468804/3 "2022-03-16T21:41:34Z")

</div>

Hey I know its been a while but do you have more info on how you got that piece of code working?

I’m not sure what the AssetDataGatherer is or how to actually set that flag

---

<div class="post-metadata">

**Author:** ![dneg\_cleu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dneg\_cleu](https://forums.unrealengine.com/u/dneg_cleu)\
**Post date:** [March 16, 2022, 10:03pm UTC](https://forums.unrealengine.com/t/how-do-i-check-assets-for-references/468804/4 "2022-03-16T22:03:13Z")

</div>

Actually no worries, I think I got it sorted.

In your code you are passing FStrings to the various GetDependencies/Referencers calls.  
Looking at this piece of the docs:

> **[GetReferencers](https://docs.unrealengine.com/4.26/en-US/API/Runtime/AssetRegistry/AssetRegistry/IAssetRegistry/GetReferencers/)**
>
> Overload list

to me it seemed like we were supposed to passing package names. When I swapped in package names for the fstrings it worked for me.
