UEFN only allows 6 buttons to activate when trying to make a Canvas UI and since i needed way more, i made my UI with Verse. The issue I am having is that I want each button to trigger their own trigger device, but i’m not sure how to go about this. The issue is that the trigger.Trigger() requires a player object as a parameter, and button.OnClick.Subscribe() sends a widget_message, the widget_message struct does have a player object. I eventually just ended up hard coding all the events, but i am wondering there is a better way to do it. My code looks something like this
@editable Triggers : trigger_device = array{}
CreateUI(Player: player):void=
MainCanvas := canvas{}
set ButtonCounter = 1
... (Anchor and offset positioning)
case(ButtonCounter):
1 =>
Button.OnClick().Subscribe(Button1Pressed)
2 =>
Button.OnClick().Subscribe(Button2Pressed)
3 =>
Button.OnClick().Subscribe(Button3Pressed)
...
set ButtonCounter += 1
return MainCanvas
Button1Pressed(Widget: widget_message): void=
if(Trigger := Triggers[0]):
Trigger.Trigger(Widget.Player)
Button2Pressed(Widget: widget_message): void=
if(Trigger := Triggers[1]):
Trigger.Trigger(Widget.Player)
Button3Pressed(Widget: widget_message): void=
if(Trigger := Triggers[2]):
Trigger.Trigger(Widget.Player)
…