I am trying to use widgets to create an inventory system and a utility belt/hot bar system. I have two separate UI’s: 1 is the actual inventory itself which only comes up when the third person character presses I, and the other is the utility belt/hot bar which is displayed at all times except when the player enters the inventory. Whenever you pick up an item, there are images over every slot that will display the specific image on the hot bar using a set brush from texture. However, I also have a hot bar within the inventory widget and I have extra slots which I want to be a replicate of the normal hot bar so the player can see what is in every slot for the hot bar. Want I have right now is an image over every slot in the inventory hot bar which, whenever the set brush from texture is supposed to affect the normal hot bar it should also affect the inventory hot bar. But I can’t seem to find out how to target the images I have placed in the inventory widget for the set brush from texture, since I have to cast to the inventory widget from the hot bar widget to get a reference to the image, i am not sure what object I should use, or if this is even possible. (I can also add screenshots of the blueprints if I haven’t explained this well-enough.).
Use this in your inventory widget and the inventory hotbar will have the same images as the separate hotbar. You’ll have to change the image widgets to the ones you use and in the get all widgets of class node set the widget class to the separate hotbar class.
Using Tick + Get All Widgets Of Class is an equivalent of shooting yourself in the foot. Not only are you executing your code every frame but Get All Widgets Of Class does not return a fixed order of elements. Have more than one Image Widget and you’re in trouble.
Create direct references to your widgets by promoting the return values of the widget create nodes. Use the references to access objects. Once you know how to use direct references, you may want to have a look at Event Dispatchers, they’re a bit more difficult to wrap one’s head around but in the end they do enhance communication.
The right hand side of Placinta8’s image shows how to set brushes; just do not do it every frame - once is more than enough.
He only has 1 toolbar widget (Not counting the one in the inventory widget). I have specified to set the get all widgets of class node to get his separate toolbar. And seriously, for this to have even a small impact on performance, you must have a very low-end PC.
Nothing to do with performance, just bad coding practice. Also, nothing personal.
edit: why was your 1st thought to diminish the potency of my beloved PC
edit2: and you’ve downvoted my answer, even though it’s good advice. Very mature.
Agreed! Tick is not appropriate here, a simple reference will do with a function call to update the brushes when necessary in each widget/hotbar. There is no need to constantly ask for “all widgets” and set their brush. It is not even possible to have changes to the inventory each frame. That is something that would happen quite infrequently as a player collects and uses items during game play.