Saving an Object of a Class

Hi, all! When I got well into the development of my game, I had to start over, because I re-discovered classes and such (I know, just bare with me).

So of course I restarted and switched to classes and development has been progressing smoothly and the elbow room and versatility that classes and class functions provide are fantastic.

My only problem here is writing a save / load function. I began writing it, and then realized that PlayerPrefs is still a viable, but extremely arduous, solution to this.

I am developing for WebPlayer. The things I need to save are purely Enums, booleans, ints, and floats.

No object position / game progress is saved. Simply the values of upgradeable things and such.

Can anyone inform me of a method other than PlayerPrefs (or if PlayerPrefs is what I need for this) that I can use for saving / loading data? I have easily over 100 variables I need to save.

(For instance, an object of an ‘Upgradeable’ class has the variables ‘Value’, ‘level’, and ‘price’, and there are 4 upgrades for each of the 8 guns 0_o

  • Am I using an incorrect method here?
  • Is PlayerPrefs what I should be using?
  • What other solutions are there?
  • Remeber - WEB development
  • Thank you for your time

Thanks! - YA

I wrote these dumb little classes as part of the github gamejam, maybe they’ll be useful to you to look at:

Async browser communications class: game-off-2012/Assets/utils.impl/n/Platform/db/impl/AsyncBrowserComms.cs at master · onethousandfaces/game-off-2012 · GitHub

Uses local storage to store values in the browser (despite the name, it doesn’t actually use cookies. :P): game-off-2012/Assets/utils.impl/n/Platform/db/impl/CookieDbContainer.cs at master · onethousandfaces/game-off-2012 · GitHub

You could also look at actually using cookies, but you’ll hit a bit of trouble; the browser won’t accept cookies if you’re using a file:// url.

Player prefs isn’t good for large amounts of info. The other solution would be to have a website backend to support your web game that lets you save data to it using HTTP requests; that’s really the correct approach to take.