Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by youngapprentice · Dec 04, 2012 at 02:31 AM · javascriptsaveload

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by doug__ · Dec 04, 2012 at 02:42 AM

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: https://github.com/onethousandfaces/game-off-2012/blob/master/Assets/utils.impl/n/Platform/db/impl/AsyncBrowserComms.cs

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

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.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image youngapprentice · Dec 04, 2012 at 02:48 AM 0
Share

And what route do most single unity web developers take? I know more than just me have completed a game.

avatar image youngapprentice · Dec 04, 2012 at 02:48 AM 0
Share

P.S I aim to have this game hosted by $$anonymous$$ongregate. I don't know if there are any perks to that like data hosting (?)

avatar image youngapprentice · Dec 04, 2012 at 02:49 AM 0
Share

Oh and thank you for the scripts. I'll check the 'cookie' (not actually cookie) one out if I end up taking that route or if I don't. Either way, information is information! :D

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Save and Load Questions 0 Answers

Null Reference Exception even after check 1 Answer

Create a terrain prefab? Saving a terrain? No? 1 Answer

nice Save but wrong load 0 Answers

Can't move after load saved game 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges