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 MrAkroMenToS · Mar 13, 2015 at 07:38 AM · saveinventorydata

Save data in Single-Player

Hi!

I need to save data such as inventory info, level and stuffs like these. I tried to save them into the Assets folder as txt file, but this doesn't work during runtime (I already read the premade files from the Assets folder, but i cannot Update them). I was thinking about regedit, but I would like to avoid using it.

How can I solve my problem?

Thanks for the reply, bye.

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
1
Best Answer

Answer by ForeignGod · Mar 13, 2015 at 07:53 AM

Lets say you played your game and got to lvl 10 You would want to save the variable Lvl 10 and load it some other time.

You can do this by doing PlayerPrefs

 var Lvl = 10;
 
 //How we are going to save your level
 
 function SaveLevel ()
 {
 PlayerPrefs.SetInt("SavedLevel",Lvl); 
 //We now stored the Lvl variable and saved it as "SavedLevel"
 }
 
 //When you press the launch button you want to execute this function.
 //Here we are getting the information we stored earlier and then inserting it into the Lvl variable
 
 function LoadLevel ()
 {
 Lvl = PlayerPrefs.GetInt("SavedLevel");
 }
 

I wrote this code in here and this is not tested, but this is just to show you how you can do it, if you want to go more in depth i suggest you read about PlayerPrefs here http://docs.unity3d.com/ScriptReference/PlayerPrefs.html

Again this is not for copy paste but merely so you understand the way to do it, atleast a very simple way.

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 MrAkroMenToS · Mar 13, 2015 at 08:10 AM 0
Share

As I see the PlayerPrefs saves into the registry which I would like to avoid as I wrote above, but If there is no other solution, I'll use it. Could you tell me some other ways, if there is any? Thanks! PS.: The reason why I wouldn't like to use it is because, I cannot move the game and the saves with it to an other computer without problem.

avatar image ForeignGod · Mar 13, 2015 at 08:52 AM 0
Share

Well you could go the hard way, using UNITY>PHP>SQL. I tried this before but it was really hard. http://answers.unity3d.com/questions/698234/sending-values-from-unity-to-php-to-sql.html

This is a question i asked awhile ago, you could probably find some of it usefull but most of it was made for my own project.

$$anonymous$$aking a database using both UNITY to PHP to a SQL database will take dedication to make it work. There might be assets already in the store, but this is what i did atleast.

If you end up using PlayerPrefs anyway make sure to call PlayerPrefs.Save when quitting the game. ^^

avatar image MrAkroMenToS · Mar 13, 2015 at 10:15 AM 1
Share

Thank you! I will use PlayerPrefs and make the player remember: when you move to an other computer, the save will be lost (or maybe I can make a save-load algorithm so the user will be able to save and load their progress) Thanks a lot! Have a nice day!

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

21 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to constantly save game progress? 1 Answer

How to save and load the game of the corresponding player by Serialization 1 Answer

How to save and load any data type? 1 Answer

IOS Serialization How To 1 Answer

How to save items purchased by a user? 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