Get Variables from Class

Hi again!

I am trying to set a variable on a widget that has been added to a scroll box, but I cannot get the variables, even when I cast it. Any ideas?

Can this be achieved in any way?

Thanks in advance.

Class - its a description of some data instance. Class itself can contain only static variables (and you cant create static in BP, afaik, only C++), all non-static variables exist only inside class instances, not in class itself.

You need to create instance of class (if its a actor class - you need to spawn actor, if its a widget class - you need to “create widget”) to access that variables.

You try to store some global data in a widget? Bad decision, i think. Place it inside GameMode or GameState.

“set a variable on a widget that has been added to a scroll box” - Widget created? Use pointer to widget returned by “Create” block instead of class pointer.

https://docs.unrealengine.com/latest/images/Engine/UMG/UserGuide/CreatingWidgets/CreateWidgetNode.jpg

Blue node “Return value” - pointer to instance, use it instead purple node of class

Thank you very much for your extremely fast response, just me not knowing how classes work.

Anyone else looking for a way to just “Pull” variables from a blueprint, you can just “get class defaults”

This will allow you to check any variables you made.

5 Likes

Amen brother! This is exactly what I needed.

Oh my gosh I’m so glad you mentioned that! I was using the old spawn method. This will help a lot.

this is the correct answer not the green one!

1 Like