# How to access default values of Blueprint assets

**URL:** <https://forums.unrealengine.com/t/how-to-access-default-values-of-blueprint-assets/60884>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [April 12, 2016, 8:34am UTC](https://forums.unrealengine.com/t/how-to-access-default-values-of-blueprint-assets/60884 "2016-04-12T08:34:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xulture](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/xulture/32/921486_2.png) [@xulture](https://forums.unrealengine.com/u/xulture)\
**Post date:** [April 12, 2016, 8:34am UTC](https://forums.unrealengine.com/t/how-to-access-default-values-of-blueprint-assets/60884/1 "2016-04-12T08:34:30Z")

</div>

Hi guys,

I’m trying to get a list of blueprints in a given content folder, and from there to get several properties to populate another asset; but I’m having difficulty obtaining GetDefaultObject()

```auto

	FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(FName("AssetRegistry"));
	IAssetRegistry& AssetRegistry = AssetRegistryModule.Get();

	TArray<FAssetData> AssetsList;
	AssetRegistry.GetAssetsByPath(FName("/Game/Objects/Props/Weapons/"), AssetsList, true);

	for (int32 i = 0; i < AssetsList.Num(); i++)
	{
		if (AssetsList*.AssetClass == FName("Blueprint"))
		{
			UE_LOG(LogTemp, Warning, TEXT("Found asset of type: %s"), *AssetsList*.AssetClass.ToString());

			TSubclassOf<AWeapon> Weapon = AssetsList*.GetAsset()->GetClass(); // always NULL
			if (Weapon != nullptr)
			{
				UE_LOG(LogTemp, Warning, TEXT("Found asset: %s"), *Weapon->GetDefaultObject<AWeapon>()->DisplayName); // we don't get this far
			}
		}
	}

```

GetAsset() returns UObject, and it’s GetClass() returns UBlueprint.

All blueprints in given folder are subclasses of AWeapon actors. How do dereference correctly to TSubclassOf\<AWeapon\>?

Assignement of UClass\* to TSubclassOf\<\> usually works when I’m dealing with correct blueprints and their parents.

Any help/comment/ideas/suggestions are greatly appreciated!

---

<div class="post-metadata">

**Author:** ![UnrealEverything](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@UnrealEverything](https://forums.unrealengine.com/u/UnrealEverything)\
**Post date:** [April 12, 2016, 10:09am UTC](https://forums.unrealengine.com/t/how-to-access-default-values-of-blueprint-assets/60884/2 "2016-04-12T10:09:03Z")

</div>

Sounds like the problem is that “AssetsList\*.GetAsset()-\>GetClass()” returns “UBlueprint::StaticClass()” which of course is NOT a subclass of AWeapon.  
Try something like this instead

```auto

UBlueprint* BlueprintAsset = Cast<UBlueprint>(AssetsList*.GetAsset());
if (BlueprintAsset)
{
	TSubclassOf<AWeapon> SubclassOfWeapon = BlueprintAsset->GetBlueprintClass();
}

```

The asset is a Blueprint so its GetClass returns the same as UBlueprint::StaticClass().  
The actual class generated by/for the Blueprint is accessible via TheBlueprint-\>GetBlueprintClass(). I’m not entirely certain this is always the case, but the UClass returned here might even be a UBlueprintGeneratedClass (derived from UClass).

Edit: actually that won’t work. I just checked UBlueprint::GetBlueprintClass and it just returns UBlueprintGeneratedClass::StaticClass() not the actual generated class that you’re looking for. There must be a way to access it although I cannot find it right now.

Edit2: aha found it, UBlueprint is derived from UBlueprintCore which has the following public member:

```auto

	/** Pointer to the 'most recent' fully generated class */
	UPROPERTY(nontransactional)
	TSubclassOf<class UObject>	GeneratedClass;

```

So the code should be something like this now

```auto

UBlueprint* BlueprintAsset = Cast<UBlueprint>(AssetsList*.GetAsset());
if (BlueprintAsset)
{
	TSubclassOf<AWeapon> SubclassOfWeapon = BlueprintAsset->GeneratedClass;
}

```

---

<div class="post-metadata">

**Author:** ![xulture](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/xulture/32/921486_2.png) [@xulture](https://forums.unrealengine.com/u/xulture)\
**Post date:** [April 12, 2016, 11:15am UTC](https://forums.unrealengine.com/t/how-to-access-default-values-of-blueprint-assets/60884/3 "2016-04-12T11:15:25Z")

</div>

That’s it!

```auto

TSubclassOf<AWeapon> WeaponClass = (UClass*)Cast<UBlueprint>(AssetsList*.GetAsset())->GeneratedClass;

```

(naturally, with appropriate checks that there are no NULLs along the way).

I had to cast GeneratedClass to UClass…? But it works well.

Thanks!!
