Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 feak1 · Jul 05, 2011 at 09:10 PM · iphoneplayerprefssave

iphone PlayerPrefs

hi im making a game for the iphone and i have a problem saving the game when the application is closed. i use a gameObject at the first scene that doesnt destroy on load so it goes through all the scenes. Heres my script i dont know what im doing wrong here!! (im trying with just 1 static var to test it)

"money.moneyT" is the static var that i want to save and retrieve when starting the game again.

function Awake(){

DontDestroyOnLoad(this);

 }

function Saving(){

PlayerPrefs.SetInt("money", money.moneyT);

 }

function Loading(){

PlayerPrefs.GetInt("money");

 }

function Start(){

 Loading();
     

}

function OnApplicationQuit(){

 Saving();
 
 

}

Comment
Add comment · Show 1
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 Benproductions1 · Mar 21, 2013 at 08:33 AM 0
Share

Please format your code! If you don't know how, watch the video on how to use Unity Answers here: http://video.unity3d.com/video/7720450/tutorials-using-unity-answers

4 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by gregmax17 · Jul 05, 2011 at 10:04 PM

I tried using PlayerPrefs before on the iPhone, but nothing would ever save. I found this by PreviewLabs, and haven't had a problem since. Might help you?

Comment
Add comment · Show 2 · 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 feak1 · Jul 06, 2011 at 07:06 PM 0
Share

thx gregmax17, but i still dont get anything saved, i did all the steps that previewlabs said to make it work for javascript.I came out with this script and i still dont see what im doing wrong!!! i dont get any errors i dont know if its the function i use or the order that the functions process...( i mean saving before loading or things like that) or should i have playerspref set to all the script that my static var are in ins$$anonymous$$d of using a single gameObject to save all the vars i need...

import PreviewLabs.PlayerPrefs;

function Awake(){ DontDestroyOnLoad(this); }

function Saving(){

PreviewLabs.PlayerPrefs.SetInt("money", money.moneyT);

 }
 

function Loading(){

  PreviewLabs.PlayerPrefs.GetInt("money");

 }

function Start(){

 Loading();
 
     

}

function OnApplicationQuit(){

 Saving();
 
 

}

avatar image gregmax17 · Jul 06, 2011 at 07:18 PM 0
Share

Don't forget to use PreviewLabs.PlayerPrefs.Flush();

avatar image
0

Answer by feak1 · Jul 06, 2011 at 07:45 PM

i did and still nothing :( whats is wrong i cant figured it out

Comment
Add comment · 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
0

Answer by Van Zeng · Nov 14, 2012 at 09:01 AM

 function Saving(){
 
 PlayerPrefs.SetInt("money", money.moneyT);
 
 PlayerPrefs.Save();
 
 }
Comment
Add comment · 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
0

Answer by madjonr · Mar 21, 2013 at 08:39 AM

OnApplicationQuit on IOS not be called

Comment
Add comment · 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

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

6 People are following this question.

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

Related Questions

PlayerPrefs Int to Float 1 Answer

How to save text and display using Touch Screen Keyboard 1 Answer

playerprefs problem 0 Answers

Playerprefs save player position 3 Answers

iPhone game keep progress after app update 1 Answer


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