I have an actor which has a static mesh and widget component. Currently im dynamically adding button widgets to the widget component via a for loop. The ForLoop gives the button an index which also sets the column (uniform grid panel). I have set up a OnClicked Event where the button which prints out its index.
I am struggling to understand how to use the OnClick event and the index inside the widget blueprint to set a variable back in the actor which is an integer (meshIndex).
Do I have to set up a custom event inside the actor?
You could just store a reference to the owner Actor inside of the widget. When the onclick is pressed, it just calls the function directly from the stored reference. That seems to be the simpliest way of doing it.
Ive set up a function which takes in the int value of the button which is pressed which sets the meshIndex int, but it doesnt work. The function will only print the meshIndex at begin play which means the button isnt changing the value?
I just added an OnClick event for the button inside the actor which sets the mesh index. Its just for testing so ive got int + int plugged into set meshIndex which when I press a button it returns a value of 1. However, the mesh doesnt change when I press play? How is that possible, the mesh selection is dependent on the int.
So I worked it out, I just had to add another int variable in the event graph with another OnClick event referencing the button. Thanks Devero, the function also helped with the process