Hi
How do you create a reference (as global or visible variable) to a widget or widget blueprint that other blueprints can use to access variables of an instance of such a widget / blueprint class?
When I create and set a variable that is a reference to an actor / blueprint class, other blueprints can read / get that variable / reference and use it to reference the variables of the blueprint pointed to
when i try the same for / with a widget blueprint, i end up with target issues when i compile, when other blueprints try to reference global variables of that widget blueprint via the instance reference provided
for an actor or instance of a blueprint class, other blueprints can read the reference variable set by the former without it requiring a target
when i do this for a widget blueprint it requires a target and it becomes circular as the reference i provide is seemingly not enough
for blueprint classes i generally set a global variable after an actor spawn. for the widget blueprint i attempt the same by setting a global variable by means of a reference to self
thanks
If I create widget and store it in a variable, I can then access itâs variables without a problem.
Maybe make sure your widget is stored as your actual Widget Class, not a generic User Widget or something
As above; and regarding making it global - there is not such thing in UE, not for this kind of behaviour. What people generally do is to keep a reference in a singleton framework class - game mode, pawn, controller. The HUD class is not choice for a widget manager â itâs accessible from anywhere via the Player Controller.
thanks. i have indeed checked that i referenced the variable type / class correctly
i still need to check whether what you have done fully corresponds to what i have done and whether it points to a possible error my side and thus a solution
one thing i can say that i have done that you have not done is that i reference from a different blueprint and you reference from within the same blueprint it seems
target is more of an issue when you reference from another blueprint
thanks
by global i mean visible to other blueprints etc. i still need to adapt to ue language
the workaround at this point is to use a âget all widgets of classâ node, seeing that there is only 1 instance of that particular widget blueprint active
perhaps referencing it in this way is a step closer to what you suggest
Theyâre always visible, by default, you just need to know where to look for references, which you must create yourself.
This is not even a workaround. Dereferenced widgets will be Garbage Collected. And you must handle comms somehow anyway since 90% of your code base is moving data from A â B.
Thereâs usually no need to use Interface communication here. You will need a Game Mode & HUD. This also assumes what @lordlolek shows in his post. There are many ways to handle it, ofc.
thanks will look into it
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.