Download

Most effective system to access variables from one User widget to another?

Hello. I’m currently working on shop with objects.

I have one main user widget(List of all objects that are loaded from an array).

I’m adding object widget this way:

Object Widget is practically 50x50 button with some own functions. It has 2 events. OnHoverBegin and OnHoverEnd. I need to access variable in Main User Widget from that object widget. But I want to do it most effectively as possible.

Thanks for future answers :slight_smile:

Create a reference of type *MainUserWidget *in *ObjectWidget *and set it to editable+exposed on spawn. Feed it with self on spawn.

I forget whether it is possible to get it’s parent, and if not do what Everynone said

Event dispatchers are awesome for this type of communication. Have a dispatcher created on your child widgets and call them from your children when they need to. When you spawn the children widgets in your main widget, bind that dispatcher to an event, or if you are adding the children pre-runtime, simply add the event like you would a button on clicked event.