Guest User

Paste in

a guest
Feb 10th, 2023
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. UFUNCTION(BlueprintCallable, meta=(DecidesOutputType="Class"))
  2. static TArray<UClass*> GetChildrenOfClass(TSubclassOf<UObject> parentClass, bool includeCPP = true, bool includeBP = true)
  3. {
  4. TArray<UClass*> Subclasses;
  5.  
  6. for(TObjectIterator< UClass > ClassIt; ClassIt; ++ClassIt)
  7. {
  8. UClass* Class = *ClassIt;
  9.  
  10. // Only interested in relevant classes
  11. if (Class->IsNative() && !includeCPP) continue;
  12. if (!Class->IsNative() && !includeBP) continue;
  13.  
  14.  
  15. // Ignore deprecated
  16. if(Class->HasAnyClassFlags(CLASS_Deprecated | CLASS_NewerVersionExists))
  17. continue;
  18.  
  19.  
  20. if (Class->HasAnyFlags(RF_Transient) && Class->HasAnyClassFlags(CLASS_CompiledFromBlueprint)) continue;
  21.  
  22.  
  23. // Check this class is a subclass of Base
  24. if(!Class->IsChildOf(parentClass))
  25. continue;
  26.  
  27. // Add this class
  28. Subclasses.Add(Class);
  29. }
  30.  
  31. return Subclasses;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment