How can I set the starting value of spinbox via variable?

Hey,

I’m trying to setup my project so the user doesn’t have to constantly type in the default value into a spin box.

To do this, I’m storing the spinbox value which the user first inputs from the menu into the gameinstance and then I’m trying to pull this value back into spinbox in the menu from the gameinstance.

I’ve done this by binding the attached function to the spinbox value field. It pulls in the variable but its locked out from there, I can no longer change its value in the UI.

Is there a way to pull a variable value into the spinbox default value field but then keep it editable?

Cheers,

When you bind a function like you did, it fires every frame and overrides the data the user tries to set manually. The only way to change this value now is to change the DurationRequest variable in the GameInstance blueprint.

You would need to reverse this setup. Rather than having the widget pull the variable from the GI, make the GI push the default variable in as spinbox value, and only when needed.

  • remove the binding from spinbox
  • when a default value needs to be displayed, obtain the reference to this widget >> get spinbox >> set value (pull it from the GI)

Alternatively:

  • remove the binding from spinbox
  • create a CustomEvent in the widget that updates the value of the spinbox using the default value pulled out of the GI

Something like this:

Do you need to keep the default value in the GI? Perhaps the widget can hold that variable, that would simplify the whole setup.

‘Set Value’ on spin box worked wonderfully. I just did this straight into the widget onConstruct.

Thanks Everynone :slight_smile: