In my blueprints I have a button that I want to change the background color of once a custom event fires. (Level Finished) when then sets the background color of the button (lvl1) to either green or gold depending on the result. Then when the widget is called, the button is painted the correct color. This works great and I have no issues with it.
However whenever I load a new level the button (lvl1) resets back to its default color and once I finish the next level the next button (lvl2) is colored but the lvl1 button has reset.
Is there an option box somewhere that I am missing? Or is there a way for me to save the color of the button so that when next it is called by the widget switcher the button stays the color it has been set to.
So, your savegame is basically just big box of variables. It looks like a BP, but don’t put code in it.
When you set the color of a widget, save it’s color in the savegame.
Next time you load the widget, if it has a color in the savegame, use that otherwise use the default color.
Here’s a tuut on savegames:
Thanks, I managed to get it to work for a single button.
Next problem is for all the buttons, I’m struggling to find information on saving an array, is there anyway to make an array a variable so that I could save it?
Put your widget buttons in an array, and have an array of colors in the savegame. They have the same indexes.
Long answer:
Like I say, the save game is just a BP. You can make an array in the variables section of the save game BP, just like any other BP.
You need to assign ( in your widget or in your head ) each of the buttons an ID, just an integer. This will be their index in the array. So, when you come to save a button you basically say:
MySavegaveButtonColors x ] = color
where x is 0 for the first button, 1, for the second etc.
When you read them, it’s just the opposite.
You need to know which button corresponds to which ID, you do this by putting all of your buttons in an array in your widget. You have to get the type of the array right ( the type of the button ), and you make the array in the construct event with the MakeArray node.
Then it’s easy because the color of MyWidgetButtonArray[6] ( for instance ) just gets saved to MySavegameButtonColors[6]…