UE4: Can't get NoesisInstance from blueprint
I'm creating my UI stuff in code, and I usually do something like this to get my widget class:
(where _C is the generated class, the blueprint is excluded from the packaged build), and it correctly loads as a UUserWidget, however when I loaded a NoesisInstance like this:
The returned class is a UNoesisBlueprintGeneratedClass, and I can't cast it to a UNoesisInstance. This means CreateWidget is fed a non-UUserWidget class and fails.
How do I get a UNoesisInstance from the generated class?
Code: Select all
const auto WidgetClass = LoadClass<UUserWidget>(this, TEXT("UserWidget'/Game/Frontier/UI/WBP_Something.WBP_Something_C'"));
Code: Select all
const auto WidgetClass = LoadClass<UNoesisInstance>(this, TEXT("NoesisInstance'/Game/Frontier/UI/WBP_Something.WBP_Something_C'"));
How do I get a UNoesisInstance from the generated class?
Re: UE4: Can't get NoesisInstance from blueprint
I tested this code and it works for me:
UNoesisBlueprintGeneratedClass inherits from UNoesisInstance, which in turn inherits from UUserWidget, so even this works:
Code: Select all
const auto WidgetClass = LoadClass<UNoesisInstance>(nullptr, TEXT("NoesisInstance'/Game/NewNoesisBlueprint.NewNoesisBlueprint_C'"));
UUserWidget* Widget = CreateWidget<UUserWidget>(GetWorld(), WidgetClass);
Widget->AddToViewport();
Code: Select all
const auto WidgetClass = LoadClass<UUserWidget>(nullptr, TEXT("NoesisInstance'/Game/NewNoesisBlueprint.NewNoesisBlueprint_C'"));
Re: UE4: Can't get NoesisInstance from blueprint
This:
https://github.com/Noesis/UE4Plugin/blo ... tedClass.h
says it inherits from BlueprintGeneratedClass
https://github.com/Noesis/UE4Plugin/blo ... tedClass.h
says it inherits from BlueprintGeneratedClass
Re: UE4: Can't get NoesisInstance from blueprint
You're right, I didn't express myself correctly.
/Game/Frontier/UI/WBP_Something.WBP_Something_C is an instance of UNoesisBlueprintGeneratedClass that contains the reflection information that describes the class resulting from compiling /Game/Frontier/UI/WBP_Something.WBP_Something. If you look at it with the debugger, you'll see that it has a member called SuperStruct, inherited from UStruct, that points to the UClass that describes UNoesisInstance. If you again look at the SuperStruct member of that UClass you'll see that it points to the UClass that describes UUserWidget. But those are native classes, so you can figure that out by looking at the code. That's what I meant when I said that UNoesisBlueprintGeneratedClass inherits from UNoesisInstance, which in turn inherits from UUserWidget. What I really should have said is that that instance of a UNoesisBlueprintGeneratedClass represents a class that inherits from UNoesisInstance, which in turn inherits from UUserWidget
If you do the same thing with the WidgetBlueprint class, you'll see that /Game/Frontier/UI/WBP_Something.WBP_Something_C is an instance of UWidgetBlueprintGeneratedClass, and its SuperStruct member points to thesame UClass describing UUserWidget as the UClass describing UNoesisInstance does.
/Game/Frontier/UI/WBP_Something.WBP_Something_C is an instance of UNoesisBlueprintGeneratedClass that contains the reflection information that describes the class resulting from compiling /Game/Frontier/UI/WBP_Something.WBP_Something. If you look at it with the debugger, you'll see that it has a member called SuperStruct, inherited from UStruct, that points to the UClass that describes UNoesisInstance. If you again look at the SuperStruct member of that UClass you'll see that it points to the UClass that describes UUserWidget. But those are native classes, so you can figure that out by looking at the code. That's what I meant when I said that UNoesisBlueprintGeneratedClass inherits from UNoesisInstance, which in turn inherits from UUserWidget. What I really should have said is that that instance of a UNoesisBlueprintGeneratedClass represents a class that inherits from UNoesisInstance, which in turn inherits from UUserWidget
If you do the same thing with the WidgetBlueprint class, you'll see that /Game/Frontier/UI/WBP_Something.WBP_Something_C is an instance of UWidgetBlueprintGeneratedClass, and its SuperStruct member points to thesame UClass describing UUserWidget as the UClass describing UNoesisInstance does.
Re: UE4: Can't get NoesisInstance from blueprint
I tested that exact code but with my class and it didn't work. WidgetClass is ok but Widget is null.I tested this code and it works for me:
Code: Select allconst auto WidgetClass = LoadClass<UNoesisInstance>(nullptr, TEXT("NoesisInstance'/Game/NewNoesisBlueprint.NewNoesisBlueprint_C'")); UUserWidget* Widget = CreateWidget<UUserWidget>(GetWorld(), WidgetClass); Widget->AddToViewport();
Re: UE4: Can't get NoesisInstance from blueprint
Have you tried stepping through UUserWidget::CreateWidgetOfClass? Is GetWorld() returning null? Or does it fail in CreateWidgetHelpers::ValidateUserWidgetClass? Regardless, I think all failure paths in that function write to the message log. Do you get an error when you run it?
Re: UE4: Can't get NoesisInstance from blueprint
It looks like I had a pickled version of the plugin, or I needed to recompile it or something. Sorry for wasting your time.
Re: UE4: Can't get NoesisInstance from blueprint
No worries. Glad you got it to work
Who is online
Users browsing this forum: Bing [Bot] and 4 guests