When setting up custom UI elements, I cannot figure out if/how the OnClick
subscribable function can be subscribed to a player. If not, this greatly limits the amount of devices custom UI can interact with.
Hi Axel,
I haven’t played around with it on my side yet, but looking at the UI API, inside Fortnite.digest.verse
and EpicGames.digest.verse
:
-
text_button_base.OnClick
canSubscribe
a function that receives awidget_message
. -
widget_message
is defined as
widget_message<native><public> := struct:
Player<native><public>:player
Source<native><public>:widget
This means you should be able to use the Player
reference to the player
that clicked the button for further processing.
ButtonTest:button_regular = button_regular{DefaultText:="ClickMe"}
OnButtonClicked(Message:widget_message):void=
# Operate on Message.Player
OnBegin<override>()<suspends>:void=
ButtonTest.OnClick.Subscribe(OnButtonClicked)
Hi @DiG3, thanks for the response!
Following the above causes an Unkown identifier 'Player'
error!
The code:
Home:button_quiet=button_quiet{ DefaultText := "Home" }
OnBegin<override>()<suspends>:void=
Home.OnClick.Subscribe(HomeSelected)
HomeSelected(Message:widget_message):void = {
GoToHome(Player) #This is a Player Function
Print("Home Selected")
if (Button := text_button_base[Message.Source]) {
Button.SetText("Home")
}
Player
is a field/member of widget_message
, so accessing it this way should work: GoToHome(Message.Player)
.
Thanks again @DiG3, I missed that. Marking as solved!
This was exactly the answer I was looking for right now, thank you @DiG3 !
Thanks for posting this question to the Forums, @AxelCapek.
I had the exact same question today, and three weeks after you asked it I was able to easily find the answer here. This is a perfect example of why the Forums are so important as an archive of community knowledge.
I’d love to upvote this post but it looks like we don’t have the functionality rn! We can only upvote posts in Issues/Bugs and Feedback. I’ll ask for one in Forums Feedback.
Edit: I requested upvoting in a Feedback post, if anyone wants to upvote my feedback about upvotes. https://forums.unrealengine.com/t/request-please-add-upvoting-feature-to-all-topics-not-just-issues-bugs-and-feedback/731375
Edit again: @Flak just added the ability to upvote posts in all categories so I upvoted this post! Thanks, Flak!