Currently I am using:
`static ConstructorHelpers::FClassFinder<UUserWidget> WidgetContainer(TEXT("/Game/Widgets/LockOnIndicator.LockOnIndicator"));
if (WidgetContainer.Succeeded())
{
WidgetComponent->SetWidget(Cast<UUserWidget>(WidgetContainer.Class))
}`
But the WidgetContainer fails to succeed. Any solutions?
Thanks in advance.
3dRaven
(3dRaven)
June 7, 2023, 9:09pm
2
static ConstructorHelpers::FClassFinder<UUserWidget>WidgetContainer(TEXT("WidgetBlueprint'/Game/Widgets/LockOnIndicator.LockOnIndicator_C'"));
UClass* WidgetClass = WidgetContainer.Class;
if (WidgetContainer.Succeeded()) {
WidgetComponent->SetWidgetClass(WidgetClass);
}
I’ve tried that but it still fails to succeed.
3dRaven
(3dRaven)
June 8, 2023, 6:42am
4
Is your LockOnIndicator widget a blueprint widget or is it a 100% c++? (UMG with parts of slate)
I get success with a bp version.
3dRaven
(3dRaven)
June 8, 2023, 6:46am
6
Are you calling
static ConstructorHelpers::FClassFinder<UUserWidget>WidgetContainer(TEXT("WidgetBlueprint'/Game/Widgets/LockOnIndicator.LockOnIndicator_C'"));
UClass* WidgetClass = WidgetContainer.Class;
if (WidgetContainer.Succeeded()) {
WidgetComponent->SetWidgetClass(WidgetClass);
}
inside of the CDO?
3dRaven
(3dRaven)
June 8, 2023, 6:51am
8
WidgetC3.zip (92.8 KB)
Here is a scene where it is implemented & working. You must be making an error somewhere else in your project.
The code is inside of MyCharacter.cpp
Duplicated your widget path so it should match.
Run it with debug enabled and you will see that it goes into the .succeed area and sets the widget correctly from class.
3dRaven
(3dRaven)
June 9, 2023, 7:54am
10
You must be doing something wrong in your code elsewhere. Here is proof it works
I trust you that it works and I’ve tested it but in my code it doesn’t succeed for some reason and I don’t know why. It says it fails to find /Game/Widgets/LockOnIndicator.LockOnIndicator
3dRaven
(3dRaven)
June 9, 2023, 8:14am
12
Because you need to add a “_C” at the end.
static ConstructorHelpers::FClassFinder<UUserWidget>WidgetContainer(TEXT("WidgetBlueprint'/Game/Widgets/LockOnIndicator.LockOnIndicator_C'"));
You are calling a blueprint not the c++ class so you need to add a suffix _C to the object type (second name after the dot)
3dRaven
(3dRaven)
June 9, 2023, 8:19am
14
is your path to the widget correct? Do you have any non-Latin letters in your asset path that might be causing problems for unreal?
Try fixing redirects on the directory with your widget.
At this point there’s not much I can help you with.
I copied the reference path provided by the engine so it should be correct. Again I appreciate all the help you’ve been over the past few days. Tysm. And sry for the back and forth hassle.
This is the path unreal engine gives /Script/UMGEditor.WidgetBlueprint’/Game/Widgets/LockOnIndicator.LockOnIndicator’
3dRaven
(3dRaven)
June 9, 2023, 8:24am
17
The reference link doesn’t really work with this type of loading
This is the reference unreal generates
/Script/UMGEditor.WidgetBlueprint'/Game/Widgets/LockOnIndicator.LockOnIndicator'
this is the path that works, you also show unreal the class of object
TEXT("WidgetBlueprint'/Game/Widgets/LockOnIndicator.LockOnIndicator_C'")
I know and I’ve tried both ways but for some reason both don’t work.
I don’t know why this doesn’t work but my animation blueprint does.
3dRaven
(3dRaven)
June 9, 2023, 8:29am
20
Can you post the snipped ot code you are using & show folder structure where the widget is in?