I know how to bind the star count, word count, and player name that’s not the problem but with a scroll box populate the scroll box with widgets for each profile.
Can someone by example or pseudocode explain how it’s done?
Ideally, you’d keep the profiles in a struct array and loop through that array, creating widgets & piping in data. Widgets can bind plain variables but can also poll from structs:
So you have text boxes and images bound to the elements in that struct. This struct variable is flagged Instance Editable and Exposed on Spawn. This way those variables appear on the node when the widget is instantiated.
The parent widget that hosts the scrollbox has an array of structs that define profile data.
So you can loop through that array and pump the data into each widget.
Thank you for your help I have 1 more question
I’m using multiple profiles and using a game instance for each profile and saving and loading the profiles with a Struct Array and a Profile struct on the game instance and the save game class.
But as I’m coding I see some problems.
By having the ProfileArray on each profile save if I delete a profile or make a new one how do I update all the profiles. is there a way to have the profile array separate that affects all the saves?
get all Scroll Box children, Loop → Cast → Update the struct variable. Discard excess widgets if you have more widgets than profiles at this point.
I’d only recommend the second method if you really cared about performance, let’s say we have thousands of profiles to update. It’s faster to update 1000 than create 1000. And if you really wanted something efficient, I’d abandon the scrollbox and look into the List View widget - super speedy but somewhat convoluted to set up.
Yes, if you need to update a save game, you need to load it, update what’s needed, save it back. Once you’ve paid the upfront cost of setting it up, it’s pretty straightforward. But you know that probably.
is there a way to make a persistent struct array that I don’t have to load or save? when the game loads with no save loaded yet the screen is blank. because I need the profile struct array before I load a game
I’m stuck on dynamic user input profiles. I need a way to make ProfileArray persistent or making the array add node to keep the values the user adds. it seems that it resets when the game shuts down. and I load it again and it’s like I didn’t add anything to the Profile Array
Well, if you need something persistent, you need to store in a save game. You cannot have something persist between the game sessions without saving.
Are you saying that when you save & then load data, the data is not correct? Operating on arrays of structs can be very tricky as BPs copy a lot of data. Look at the icon on the For Each Loop node - it’s a dot - that’s a copy of the data. A diamond represents data passed by reference.
You need to ensure you pass data by reference and, in certain scenarios, additionally push the data back into arrays.
Sure. You can have multiple arrays of structs in a save game as separate variables. Also, nothing really stops you from having and array of struct arrays containing arrays of struct arrays containing struct arrays… you get the gist!
It just becomes more difficult to update. It’s a pretty normal way of working if you have a multi-layered procedural generation that you need to save and restore.
I’ve gone as deep as 7 nested structs arrays. Is it fun - no? Is it pretty - hell, no! Does it work - yeah.