Access widget variable from game instance?

Hey guys, I have a Editable text box in my Widget and a game instance which have the reference to my widget.
However, the widget reference have no access to the editable text box. What could be the problem? Thanks

Engine is 5.0.3

Things I check:

  1. Set GameInstance as project game instance.
  2. Check the Editable text box Is Variable.

image
New added image (above)

Game Instance (above)

Widget (above)

The reference is a generic widget reference. You either have to cast to get the right type, or make the variable ( reference ) of the correct type.

2 Likes

Thanks ClockworkOcean,
Sorry I forgot to show how I got the reference.


I store the reference when I create this widget and just like my question, I couldn’t access it’s variable.

(thanks hero)

To check, you should be able to do it in one shot

This

is WB Main menu?

1 Like

Yes the WM Main menu is my widget, that image is the screenshot of that.

I create a user widget to store the reference. When I use the return value from the Create WB Main Menu Widget node I can access my variable. But my User Widget reference can not accuess it. Is that a variable type thing? Thanks.

Does the one-shot test work?

1 Like

Yea the one shot work great. I am able to get the variable. Thanks.
Just wondering why that’s the case.

Ah. You made the variable by hand, right?

It’s the wrong kind. Because it’s a generic widget variable, it can hold the value, but it’s of the wrong sort to find the variable.

It’s a good idea to always make variables, by right clicking on the output pin, and choosing ‘promote to variable’. :slight_smile:

Then it should work.

Does that make sense?

1 Like

Thanks. I got it now.

Yea I make it by hand, don’t know there was this generic widget variable thing. Kind of new to programming. Right click to promote variable seem much safer.

Thanks again~~ :wink:

1 Like

It’s blueprint inheritance.

If you make a class like, MyEnemy. And then children from it, MyEnemy-typea, typeb etc. Then a reference of type ‘MyEnemy’ will be able to hold them all. But, variables only available in typea will not be visible from that reference until you cast :slight_smile:

1 Like