# Getting blueprint assets with the asset registry in packaged builds?

**URL:** <https://forums.unrealengine.com/t/getting-blueprint-assets-with-the-asset-registry-in-packaged-builds/2794483>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, Packaging, question, CPP\
**Created:** [September 17, 2026, 9:53am UTC](https://forums.unrealengine.com/t/getting-blueprint-assets-with-the-asset-registry-in-packaged-builds/2794483 "2026-09-17T09:53:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![NuclearApplejack](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NuclearApplejack](https://forums.unrealengine.com/u/NuclearApplejack)\
**Post date:** [September 17, 2026, 9:53am UTC](https://forums.unrealengine.com/t/getting-blueprint-assets-with-the-asset-registry-in-packaged-builds/2794483/1 "2026-09-17T09:53:47Z")

</div>

I need to get the `UClass` and the CDO of every blueprint in a specific folder that is derived from a class `UMyClass`.  
In order to do this, I’m using the asset registry to load all `UBlueprint`s in the folder.  
Here is a simplified version of the code I’m using:

```cpp
const FAssetRegistryModule& assetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");
assetRegistryModule.Get().SearchAllAssets(true);
 
FARFilter filter;
filter.PackagePaths.Add(FName("/Game/GameContent/MyFolder"));
filter.bRecursivePaths = true;
filter.ClassPaths.Add(UBlueprint::StaticClass()->GetClassPathName());
 
TArray<FAssetData> bpAssets;
assetRegistryModule.Get().GetAssets(filter, bpAssets);
 
for (const auto& bpAsset : bpAssets)
{
	const UBlueprint* blueprint = Cast<UBlueprint>(bpAsset.GetAsset());
	TSubclassOf<UMyClass> bpClass = TSubclassOf<UMyClass>{blueprint->GeneratedClass};
	const UMyClass* bpCDO = bpClass->GetDefaultObject<UMyClass>();
	// Do stuff with the class and the CDO
}

```

This works fine in the editor, but fails in packaged builds (apparently the `bpAssets` array does get populated, but the cast to `UBlueprint*` inside the for loop seems to fail).  
From what I understand, `UBlueprint`s are replaced with `UBlueprintGeneratedClass`es in packaged builds, so I’m assuming this is the issue? I’m not sure how to rewrite this code to make it work both in the editor and in packaged builds, though (adding `UBlueprintGeneratedClass::StaticClass()->GetClassPathName()` to the filter’s class paths and casting to `UBlueprintGeneratedClass*` in the loop did not seem to solve the problem).  
Any help would be appreciated. Thanks in advance!

---

<div class="post-metadata">

**Author:** ![AlienRenders](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AlienRenders](https://forums.unrealengine.com/u/AlienRenders)\
**Post date:** [September 17, 2026, 3:56pm UTC](https://forums.unrealengine.com/t/getting-blueprint-assets-with-the-asset-registry-in-packaged-builds/2794483/2 "2026-09-17T15:56:09Z")

</div>

Yeah, UBlueprint doesn’t exist in packaged builds.

I used this for the class:

```cpp
  UClass* TargetSearchClass = GIsEditor ? UBlueprint::StaticClass() : UBlueprintGeneratedClass::StaticClass();

```

And when casting in your loop, I do this:

```cpp
    UClass* CompiledClass = nullptr;

    if (GIsEditor)
    {
      // Editor path
      UBlueprint* BlueprintAsset = Cast<UBlueprint>(bpAsset);
      if (BlueprintAsset)
      {
        CompiledClass = BlueprintAsset->GeneratedClass;
      }
    }
    else
    {
      // Packaged Build Path: Skip UBlueprint entirely and load the compiled type direct
      // Cooked builds append "_C" to the string path of the object class definition
      FString ClassPath = bpAsset.GetObjectPathString() + TEXT("_C");
      CompiledClass = StaticLoadClass(UObject::StaticClass(), nullptr, *ClassPath);
    }

    // Now use CompiledClass to get CDO.
    // Example:
    TSubclassOf<AActor> MyClass = CompiledClass;
    AMyActor* MyActor = MyClass->GetDefaultObject<AMyActor>();

```

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [September 18, 2026, 3:32am UTC](https://forums.unrealengine.com/t/getting-blueprint-assets-with-the-asset-registry-in-packaged-builds/2794483/3 "2026-09-18T03:32:44Z")

</div>

also make sure the asset is set to AlwaysCook or it may not get packaged at all

---

<div class="post-metadata">

**Author:** ![AlienRenders](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AlienRenders](https://forums.unrealengine.com/u/AlienRenders)\
**Post date:** [September 18, 2026, 9:06pm UTC](https://forums.unrealengine.com/t/getting-blueprint-assets-with-the-asset-registry-in-packaged-builds/2794483/4 "2026-09-18T21:06:12Z")

</div>

I ran into an issue with my code above. If you run in standalone mode, it won’t work. Instead of using GIsEditor, you need to do something like this:

```auto
const bool IsBP =
#if WITH_EDITOR
  true;
#else
  false;
#endif

```

Then use IsBP instead of GIsEditor everywhere in the original code. It should now work in editor, standalone and packaged build.

---

<div class="post-metadata">

**Author:** ![NuclearApplejack](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NuclearApplejack](https://forums.unrealengine.com/u/NuclearApplejack)\
**Post date:** [October 1, 2026, 12:46pm UTC](https://forums.unrealengine.com/t/getting-blueprint-assets-with-the-asset-registry-in-packaged-builds/2794483/5 "2026-10-01T12:46:33Z")

</div>

For some reason (maybe different engine version?), in my case, the string obtained from `bpAsset.GetObjectPathString()` already had the `_C` attached at the end. I removed the `+ TEXT("_C")` part, and it worked perfectly!
