- Home /
Storing GameObject(s) Playerprefs?
Hi there! I just wanted to know if it's possible to store gameobject in playerprefs? If I'm going into details: I currently have a script that tells you what weapon you're welding (var weaponInUse : GameObject[];) and i just want to know if it's possible to store the current weapon (gameobject) in playerprefs. If not, give me some examples to store them, thank you. :-)
well you'd just store that as an integer ok ? So just use SetInt and GetInt
well, the guns are in a variable that is used called as an GameObject. I don't really think that you can call SetInt on a GameObject? correct me if i'm wrong
Answer by Loius · Apr 08, 2013 at 05:41 AM
No, since that's essentially (or maybe is actually) a pointer, and it's nowhere near guaranteed to be the same in a subsequent run.
Instead you need to say "This bazooka is Gun 5" and so you save a 5 as your current weapon. If you build it nicely it'll be simple to just use an array index as the gun ID.
oh, I get it. Yeah, I'll look into the index'es for the guns. Thanks! I'll let you know if I got it to work!
I did enter the gun Id script. And wrote the playerprefs. Strangely it didn't work :-\
Any other ideas?
(I used SetInt and GetInt because the variable is an integer)
you've made some simple code errro. CLIC$$anonymous$$ EDIT on yoru question above and paste in all the relevant code
Post my weapon index script or my weapon manager script? (it's like 600 lines xd)
But I'll paste my weapon index script when I come home. Currently in school
augh just the relevant stuff, like the save and load functions and the weapon array
Your answer
Follow this Question
Related Questions
PlayerPrefs for saving strings 1 Answer
Problems with saving/loading score with PlayerPrefs [C#] 1 Answer
DeleteAll not working on android? 0 Answers
"If there is no save data" or "If there are no PlayerPrefs" 2 Answers
Saving Data! PLEASE HELP 1 Answer