Referencing meshes inside widget blueprint event graphs

Hello!

Can anyone tell me how to reference a mesh inside a widget blueprint?

I have a button in my widget blueprint that I want to use to toggle the visibility of one of the meshes in my scene. I’ve created the button and created an “OnClicked” event in the event graph, but I can’t work out how to reference the mesh that I want to make visible/hidden in game. Is it something to do with casting it to another blueprint?

I’m still wrapping my head around widget blueprints (and blueprints in general), so any pointers would be greatly appreciated :slight_smile:

Have you tried selecting the mesh in question from the world builder, right clicking anywhere on the bluprint graph and selecting “get reference to xxxx”?

Hey 6ixpool, yeah, that method works in level and class blueprints, but not in the widget blueprint event graph. Dragging and dropping from the content browser doesn’t work either

The following tutorial may help you understand how to communicate more effectively with other Actors from Widgets.

Alternatively what you need is to pass the Reference to your Object into the Widget Blueprint when it is created if that is at all possible.

That’s because you can’t reference it directly like that. The things that happen in a level blueprint can’t happen in other blueprints because then on another level that actor wont exist.

What you will need to do is get an exact reference to the actor that you want. There are multiple ways that you can achieve this. Depending on how you are showing the widget. If you are showing it once you click on the actor or something then just use the reference to that actor.

How are you showing the widget and/or how are you interacting with the actor

DevilsD: Thank you! That was really helpful. I’m not able to try it out tonight but that’s definitely cleared up a lot. I’ll see if I can get something working in the morning.

ZoltanJr: the widget button is always displayed on screen (this is for an archviz project) and would just allow the user to toggle the visibility of the mesh on and off, which in this case is just a ceiling element that isn’t able to be directly interacted with. Hopefully I can get it working with DevilsD’s info but if you have any other suggestions let me know!

Alright, so despite DevilsD’s great tutorial I can’t seem to understand how to apply the logic to my own widget blueprint.

What I want to do is much simpler than what was shown in the tutorial - the widget is constantly displayed onscreen (therefore no need to create and remove it), and it’s used to toggle the visibility of a mesh in the scene when clicked. I understand that you need to pass the events from the widget BP to the class or level BP, but I don’t understand the creation of custom events, or how to reference a single widget button from an array of widget buttons. Again, any help would be hugely appreciated.

EDIT: Not sure what was going on but I got it working by starting afresh