i’m creating a character selection and i’ve added a system to buy the characters with credits ingame but i have a issue:
i would like to save with PlayerPrefs the bought characters, i tryed this:
PlayerPrefs.SetInt (ToString(character), unlockedCharacter[character]);
character is the number of the selected character
what i was expecting is that it set int to 0 if it isn’t bought and 1 if it’s bought.
but this isn’t working, i’m new to scripting with unity.
What does “it isn’t working” mean? Compile error? Run-time error? Silently fails to set the playerpref? Sets the playerpref to the wrong value? Transfers the contents of your bank account to a prince in Nigeria?
Tell us what it does, not one particular thing that it doesn’t do.
But you didn’t save an array, you saved an integer with a key of ToString(character). I see that saving an array is conceptually what you’re trying to do, and there may be better ways of doing that, but that doesn’t explain what’s going wrong with your current attempt.
Did you call GetInt using the same key (i.e., ToString(character)) that you used when calling SetInt?