Download

[Feature] Get purple class node from asset registry instead of "text"

This allows me to pull a list of classes of all my weapons, or character, or body parts, so I can generate widgets, for a drag n drop operation, Once dropped, I spawn the actor from the class.
In the case of world, I don’t use my function, but I do use it to pull a list of all levels in a certain folder. This prevents me from hardcoding a list for every little thing thats ALREADY organized by folder. You can even disable/enable recursive search for more control


// Get UClass from asset in AssetRegistry
// You have to include "AssetRegistry" in your projects Build.cs modules list!!

//When searching for assets use:
//Turn off: Filter Include Only on Disk Assets

//NOTE: Setup in ProjectSettings :: AssetManager is required!
//You have to add your asset type, and the folder location, for this to WORK IN STANDALONE.
//Also, make sure you enable "Has blueprint classes"
//If I want all my body part types, the target asset is BodyPart_Base, as this will cover all the children
//Also, all my assests per type are in their own folder, to make it simpler to add to the settings

//NOTE ABOUT MAPS:
//In project settings, for asset manager:
//Find the Primary Asset Type: Map
//and make sure that :
//Is editor only is turned off!

//If you want other things like GameModes to be searchable like this, you need to add those to the asset registry in project settings as well
TArray<UClass*> UMyBlueprintFunctionLibrary::GetClassFromAssetData(TArray<FAssetData>& InAssetData)
{
    TArray<UClass*> ClassArrayOut;
    ClassArrayOut.Empty();
    // Iterate over retrieved blueprint assets
    for (FAssetData asset : InAssetData)
    {
        FString ObjPath = asset.ObjectPath.ToString().Append("_C");
        //UE_LOG(LogTemp, Warning, TEXT("Object path is : %s"), *ObjPath);
        //UE_LOG(LogTemp, Warning, TEXT("Trying to return BPClass!"));

        //Get UClass
        ClassArrayOut.Add(StaticLoadClass(UObject::StaticClass(), NULL, *ObjPath, NULL, LOAD_None, NULL));
    }
    return ClassArrayOut;}

Edit: The new built in “Get Class” node for AssetData, does NOT get the blueprint class, instead it gets the “file type” class. You would still use my code instead.