I know I can add them manually before runtime.
I wanted to set it up so I could make new classes at a later date, without having to constantly update the list manually.
I have been looking for a way to do this as well and unable to find a solution, but have found a decent compromise:
If you add an array of the Parent type to a Blueprint (say, your Controller), you can go into the Defaults tab of that Blueprint and fill the array manually there using the dropdowns. It’s faster and cleaner than doing it with Event Graph nodes.
It would be useful to have such functionality.
In UMG when creating list of items able to pick up or buildings to build - now I need to make data tables or arrays, which on the long run can be messy and unreliable.
Getting one array of classes derived from one particular class would solve quick feeding scroll list, combo boxes etc.
This is a old post but here is a solution using UObjectLibrary. Loading asset can take times.
UObjectLibrary* MyObjectLibrary = UObjectLibrary::CreateLibrary(AMyActor::StaticClass(), true, true);
All you have to do is to find your class in the list and build the “generated class” (i.e. the class that represents your blueprint):
for (FAssetData const& BlueprintAsset : BlueprintAssets)
{
const FAssetTagValueRef GeneratedClassTag = BlueprintAsset.TagsAndValues.FindTag(FName("GeneratedClass"));
if (GeneratedClassTag.IsSet())
{
FTopLevelAssetPath ClassPath(GeneratedClassTag.GetValue());
if (DerivedClassNames.Contains(ClassPath))
{
// Now we can retrieve the class
FStringBuilderBase Builder;
Builder << BlueprintAsset.PackageName << '.' << BlueprintAsset.AssetName << "_C";
}
}
It sets the FileNames TArray to a list of strings of the names of all the files found in SearchDirectory. I then prune the extension from the file names, and use this during game startup:
I use this for automating items in my game allowing newly created ones to be added to things like chests without having to manually add them to arrays for each new item