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
1
Question by Riliali · Oct 10, 2010 at 01:20 PM · iphonesaveloadscoreboard

How to script a Save/Load option on IPhone?

Hi! I was doing some research, but I couldn`t find a simple way for recording some information in IPhone. I want do know how save simple data, like de PlayerPrefs, but without loosing them after the program is closed. I want basically save the options of the player and also the local scoreboard of the game. I would really appreciate any help, thx!

-------- EDITED ---------

Like my friend there told me, PlayerPrefs should me saving the variables even when the game is turned off. So now my problem becomes the follow: " Why am I loosing de PlayerPrefs just when my game is closed "? This is where a think the problem is:

function Start(){
    if ( !PlayerPrefs.HasKey("level") ){
        PlayerPrefs.SetInt("level", 2);
        PlayerPrefs.SetInt("sound", 1);
        PlayerPrefs.SetInt("music", 1);
        PlayerPrefs.SetInt("skin", 1);
    }
    iPhoneSettings.screenOrientation = iPhoneScreenOrientation.Landscape;
}

This is the code executed in my menu screen. I check if the level have already been set, if not ( meaning that this is the first time that the game is running ) I put the values of the PlayerPrefs to the default ones. I'm doing it right? Just remember that if a go to the menu screen during the game, the PlayPrefs continue normal. But if I quit, they come back to the default ones...

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 duck · Oct 10, 2010 at 01:30 PM

The data stored usingPlayerprefs should not be lost after the program is closed, so it's ideal for your needs.

Comment
Add comment · Show 7 · 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 Riliali · Oct 10, 2010 at 02:41 PM 0
Share

No, you are wrong. The PlayerPrefs are lost after closing the game. $$anonymous$$aybe you are getting confused because when you pause the application, you don't lose the PlayerPrefs, but you can see under the applications that are still running ( double press the IPhone button ) that the game is still there. You can quit the game by holding the finger on the applicantions that are running and them pressing the red button, or turning off the IPhone.

avatar image leith · Oct 11, 2010 at 12:53 AM 0
Share

Actually, its right. Something must be wrong with your implementation. In my game, closing out of the unity app as you describe and forcing a complete restart does keep the player prefs that I've saved.

avatar image Riliali · Oct 11, 2010 at 01:14 AM 0
Share

Yes man, you are absolutely right! Sorry if I was rude. But my problem persists... Thanks for the help anyway!

avatar image duck ♦♦ · Oct 11, 2010 at 06:39 AM 0
Share

$$anonymous$$aybe you could edit your question to include the code you're using to save your data, so we could see if there are any problems with it.

avatar image duck ♦♦ · Oct 11, 2010 at 06:41 AM 0
Share

Oh, you did. The code looks okay. Now post the code where you read the values back out!

Show more comments

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

1 Person is following this question.

avatar image

Related Questions

player prefs, problem but no problem??? 1 Answer

Load XML File ? 1 Answer

Save variable value. 1 Answer

Saving data 1 Answer

Why wount my saving script save properly ? 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