|
Hi I've been at this all day an have gotten nowhere. I have a script for a message system and I've decides to use PlayerPrefs to save and load messages so they remain after the game has been closed and reopened. I get no script errors but for some reason when I close and open the app, posted messages are not reloaded. If anyone can tell me what's wrong with what i've done I'd be so grateful. Here's the javascript code I've been working on: Thanks again!
(comments are locked)
|
|
PlayerPrefs.GetString returns the value from PlayerPrefs. See http://unity3d.com/support/documentation/ScriptReference/PlayerPrefs.GetString.html Fixed code: GetString is currently in my code already within function GetMessages.
Aug 17 '11 at 08:04 PM
blacksuit_films
But you are not using what it returns. It should be something like: var result: String; result = PlayerPrefs.GetString(nameField); Also - it does not make sence to use the second parameter (default value) when you check that the item do exist.
Aug 17 '11 at 08:09 PM
Mortennobel
Another issue - you are always saving the constant "Name" - that looks like a bug. I think you have swapped the parameters. Take a look at the documentation. (Read what the parameter are called)
Aug 17 '11 at 08:13 PM
Mortennobel
Okay, I sortof see what you mean. I think my main misunderstanding here is the var and string at the beginning of your proposed code. what would I put in as the result for the var and string? Apologies but filling in the blanks isn't something I'm good at.
Aug 17 '11 at 08:14 PM
blacksuit_films
I don't understand the documentation theres not enough info for a newbie. The only way for me to learn this properly is to see it done but there are no tutorials.
Aug 17 '11 at 08:19 PM
blacksuit_films
(comments are locked)
|
|
Gotcha... It says loadedName. I really appreciate you taking the time to help me here.
(comments are locked)
|

Without looking at your code yet, you do know there is a limit to how much you can store prefs, right? Is it possible you've gone beyond that limit?
It's okay I' know that there is a 1MB limit. I have had no results as yet with this code. So far I have only used 4KB of that space