Cycle through existing UClass types from base type

Is there a way to acquire an array of UClass pointers by providing a base UClass pointer? For example,

TArray<UClass> animals = ()->GetBaseClasses(AAnimal::StaticClass());

Then if I have a Bird, Dog, and Cat, I’ll get UClass pointers to each of those types in indices 0, 1, & 2?

I can’t find this function in either API reference or engine source code, but yes as all arrays, results would be indexed with numbers from 0 to somewhere. Also i think it should be TArray, arrays can hold normal data including structs and non-UObject classes too, not only pointers, so they need be distinguished.

Oh, I wasn’t suggesting that the function I specifically wrote existed. I just meant I was looking for something that would work like that. I couldn’t seem to identify anything in the API that explicitly retrieved these derived UClass pointers from a base one, and I was wondering if somebody else knew of one that I couldn’t find.

Seems there no way, i checked class viewing examples in editor code and all they do is iterate UClass objects on there own (which exist and it’s made for every UObject class).

So you need to do:

for(TObjectIterator<UClass> It; It; ++It) {
     //filter classes
}

and catch classes you need, in your case you would do that via GetSuperClass() function

or ISChildOf(class)

This will go thru whole class hierarchy so it might be too expensive to do that on every frame, i recommend to generate array on beginplay and keep it