Search Unity

Resolved Saved variables not updated after the first initial save

Discussion in 'Visual Scripting' started by CameronDWills, May 9, 2022.

  1. CameronDWills

    CameronDWills

    Joined:
    Feb 26, 2021
    Posts:
    91
    I have a script that saves a list of strings to a visual scripting saved variable. The first time this script is ever ran, the application saves the list to the saved variable perfectly so even after the application is closed, the list persists.

    However, running the script subsequent times and updating the list with new values will update the saved variable while running, but as soon as the application closes, the saved variable data reverts back to the original saved variable values. Is this a bug or is there supposed to be some other way to update the data in previously saved values so it overwrites the old data and becomes the new saved data?
     
    Ignacii and MaximeChaos like this.
  2. Elidrin

    Elidrin

    Joined:
    Nov 4, 2021
    Posts:
    6
    This may sound silly but when you look at the variables tab you will see 2 tabs. One for Initial values and one for saved. Are you checking the correct tab? I ask because I have done this and I spent 20 minutes looking for something wrong when it was just me looking at wrong place.
     
  3. CameronDWills

    CameronDWills

    Joined:
    Feb 26, 2021
    Posts:
    91
    It looks like saved variables aren't able to store lists
     
  4. REDACT3D_

    REDACT3D_

    Joined:
    Nov 8, 2020
    Posts:
    222
    hard to say without seeing the graph, but are you certain that you're telling the variable to save after setting it? sounds like it from how it's workin' at the start.

    an image of the graph may help figure out the issue
     
  5. ericb_unity

    ericb_unity

    Unity Technologies

    Joined:
    Nov 24, 2017
    Posts:
    167
    Are you just settings values on the saved variables or actually saving the variables?

    Can you try to add a "Save Variables" node to see if is save.
    upload_2022-9-29_9-46-3.png

    You if you don't see your saved variables, it mean we have an issue with some types.
    upload_2022-9-29_9-53-53.png
     
    Ignacii, MaximeChaos and REDACT3D_ like this.
  6. CameronDWills

    CameronDWills

    Joined:
    Feb 26, 2021
    Posts:
    91
    I didn't realize there was a 'save variables' node, I thought using a 'set saved variables' node would be enough to save it. I'll give this a try and report back
     
    ericb_unity likes this.
  7. MaximeChaos

    MaximeChaos

    Joined:
    Apr 8, 2017
    Posts:
    13
    Being used to the Bolt way of doing things, I had the exact same problem (only set the saved variables without any "Save Variables" node and was expecting to get the same results as before).
    I'm glad I found this thread, but to be fair, I first searched quite a lot the solution inside the wiki and didn't find anything. I think that the wiki should be updated with this very important piece of information.

    If you type ["Save Variables node" unity] on Google there is only one result: this thread! Haha.

    Anyway, thanks a lot for the help, it worked perfectly for me! Have a nice week!
     
  8. REDACT3D_

    REDACT3D_

    Joined:
    Nov 8, 2020
    Posts:
    222
    Yeah me too haha

    Now I use setups like this revolving around the Subgraph.

    Take this example:
    Inside a Subgraph, I set a bunch of Save values and save it all once before exiting.


    This is what the Front-End of the Subgraph looks like:
    Capture1.PNG


    And here are the guts:
    Capture.PNG


    And this is what it would look like with a bunch of random crap plugged in to save:
    Capture2.PNG


    I found that you don't need to add a placeholder for the data previous to storage, the Set Save node will generate the instances of the variables for you in the blackboard. i guess that means this could scale easy
    Capture3.PNG
     
  9. qngnht

    qngnht

    Joined:
    Jan 24, 2022
    Posts:
    24
    Thank you so much guys ! must add node [ Save Variables ] after [ Set Saved Variable ] ^ ^
     
    Kruqs, ericb_unity and REDACT3D_ like this.