So basically I am trying to load a widget from an UGC package. But when I try to cast the widgetclass to its superclass, the cast just returns NULL.
relevant cpp code excerpt:
for (FUGCPackage& package : UGCRegistry->UGCPackages) {
TArray<UClass*> Classes;
UGCRegistry->GetAllClassesInPackage(package, Classes);
for (UClass* currentClass : Classes) {
if (currentClass->IsChildOf(UAppIconSuperclass::StaticClass())) {
if ("appIcon_C" == UKismetSystemLibrary::GetClassDisplayName(currentClass)) {
if (Cast<UAppIconSuperclass>(currentClass) != NULL) {
GEngine->AddOnScreenDebugMessage(-1, 100, FColor::Green, "valid"); // doesn't print -> cast failed
}
if (currentClass) {
GEngine->AddOnScreenDebugMessage(-1, 100, FColor::Green, "was valid"); // does print -> class is valid
}
I know that the class has got UAppIconSuperclass as parent, and first if check let’s it through, so why does the cast fail? I also tried to cast to UUserWidget (parent class of UAppIconSuperclass) - with the same result…
Is anyone able to help me and tell me what I am doing wrong / why it wouldn’t cast correctly?