Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- UFUNCTION(BlueprintCallable, meta=(DecidesOutputType="Class"))
- static TArray<UClass*> GetChildrenOfClass(TSubclassOf<UObject> parentClass, bool includeCPP = true, bool includeBP = true)
- {
- TArray<UClass*> Subclasses;
- for(TObjectIterator< UClass > ClassIt; ClassIt; ++ClassIt)
- {
- UClass* Class = *ClassIt;
- // Only interested in relevant classes
- if (Class->IsNative() && !includeCPP) continue;
- if (!Class->IsNative() && !includeBP) continue;
- // Ignore deprecated
- if(Class->HasAnyClassFlags(CLASS_Deprecated | CLASS_NewerVersionExists))
- continue;
- if (Class->HasAnyFlags(RF_Transient) && Class->HasAnyClassFlags(CLASS_CompiledFromBlueprint)) continue;
- // Check this class is a subclass of Base
- if(!Class->IsChildOf(parentClass))
- continue;
- // Add this class
- Subclasses.Add(Class);
- }
- return Subclasses;
- }
Advertisement
Add Comment
Please, Sign In to add comment