0
\$\begingroup\$

I have a AoT Dictionary called AlphabetWidth that I fill with data I generate when my game starts. I mark this variable as "saved", as described here

enter image description here

I generate the dictionary data inside of a GameObject that I call, "Dictionary Generator". My ideal workflow would be:

  1. Turn on Dictionary Generator once, and run it. Now the Dictionary data is saved.
  2. Now I turn off the Dictionary Generator game object, since I don't need it to run anymore.
  3. Now when I need the Dictionary data in the future, I can just access it.

But I'm running into problems with this workflow, and am realizing it's probably because

a) I'm turning off the Dictionary Generator game object and I'm guessing that turns off the saved data inside of it

b) Because I lack a conceptual understanding of how saved variables work (researching that one now).

I am leaning towards running it once and exporting the data into CSVs, and then whenever I run the game again... using Split Strings to read it into a dictionary. Then I can easily access it. But this seems very kludge-y and I'm wondering if there's a better way.

What's the best practice for accessing saved data like this when I need it... should I just write the data into strings, and On Start... use String Split to split it into a Dictionary? Should I learn how PlayerPrefs work and put the data into there?

Or is there a simple way to access saved variables (generated in game by a game object which is later disabled) that I am missing?

\$\endgroup\$
5
  • \$\begingroup\$ 1. Turn on Dictionary Generator once, and run it. Now the Dictionary data is SAVED. What does saved means? You mean it is stored locally somewhere (the definition of saved?) or is it just assigned in your dictionary. \$\endgroup\$
    – Zibelas
    Jun 13 at 10:05
  • \$\begingroup\$ I mean the SAVED variable type here: docs.unity3d.com/Packages/com.unity.visualscripting@1.5/manual/… \$\endgroup\$
    – kanamekun
    Jun 13 at 10:08
  • 1
    \$\begingroup\$ The documentation says they are stored in playerprefs. You can't deactivate player prefs by just deactivating the game object. They are stored on your device - that means as well if the generator is not run first on a new device, if you try to acccess them, they will be always empty. But it should persist between runs already. Playerprefs are just a stored key - value pair. You should not need to write your own parsing/ loading/ storing for this \$\endgroup\$
    – Zibelas
    Jun 13 at 11:05
  • 1
    \$\begingroup\$ Is there not a visual script component reparding playerprefs? Since you store a float, it should be a get float one. Your key is your string. \$\endgroup\$
    – Zibelas
    Jun 13 at 11:56
  • \$\begingroup\$ A quick google found this youtube tutorial that shows how to save/ load and reset from playerpref using bolt. youtube.com/watch?v=nR1OOJcy47Y \$\endgroup\$
    – Zibelas
    Jun 13 at 13:52

0

You must log in to answer this question.

Browse other questions tagged .