here is WidgetUI.
and I’m trying to get ChatBox(EditableTextBox) in c++ code
i made this variable in Header file.
][3]
this is the cpp code.
if i run this, problem occurs from that Cast.
_chatBox is null.
it’s in BeginPlay()
i think there is no reason _chatBox is null.
what do you think is the problem?
Hello! Can you recheck Cast? Everything other seem ok to me…
Tuerer
November 5, 2021, 10:56pm
3
Just do this in .h:
UPROPERTY(meta = (BindWidget))
class UEditableTextBox* _chatBox;
It will automatically work without the need to cast anything.
MyxaWW
November 8, 2021, 10:29pm
4
alternatively this worked for me
WidgetTree->ForEachWidget( [this]( UWidget* Child )
{
if (auto* TextBox = Cast<UEditableTextBox>( Child ))
{
// do something
}
} );
I found the problem, it was because i ran in listen server with a few clients. clients had no widget assets assigned so i put them all in game instance not to lose them and it worked for me!