Somber
Somber

Reputation: 443

Creating a set of buttons with oncick events on them

I have an array of objects in my game, and I want to create buttons in the UI, based on object count in array. In menu construction script, array is scanned for objects, and for each of them button is created, and labeled by object name.

Now I want to do onclick event for these buttons which will display info about respective object in the UI. So I need to somehow create a onclick event for each of appearing buttons, or create universal onclick event for this group of buttons, which will read object name from button and search for that in the array. Is it possible to create events for objects which are going to appear during game? Please suggest.

Upvotes: 0

Views: 2910

Answers (2)

Somber
Somber

Reputation: 443

Workaround - by onclick event get buttons array and find which is hovered by mouse ATM

enter image description here

Upvotes: 1

mattia biggeri
mattia biggeri

Reputation: 41

you could make a widget object containig the button with the onclick event, then in the contruction script you create the widgets. Here you can find some documentation for widgets: https://docs.unrealengine.com/en-US/Engine/UMG/UserGuide/WidgetBlueprints/index.html https://docs.unrealengine.com/en-US/Engine/UMG/UserGuide/CreatingWidgets/index.html

Upvotes: 0

Related Questions