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 DubstepDragon · Jun 12, 2013 at 08:16 PM · playerprefsmonodevelopint

Saving an int via PlayerPrefs...

I have a value of gold that the player collected stored in an integer. However, how would I save this using PlayerPrefs(in C#)?

Thanks in advance!

Comment
Add comment · Show 8
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 clunk47 · Jul 19, 2013 at 05:19 PM 1
Share

Voted you back UP to zero, not sure why someone voted u down lol

avatar image DubstepDragon · Jul 22, 2013 at 06:13 PM 2
Share

Oh thx! I dunno, retards on this network, say stuff like "YOU N00B AS$$anonymous$$ING FOR SCRIPTS!" when all I am doing is asking for assistance...

avatar image clunk47 · Jul 22, 2013 at 06:18 PM 1
Share

Well you didn't just ask for a script like some people. If someone gets on here and says "Give me a script to do this", I usually bitch at them haha XD

avatar image DubstepDragon · Jul 22, 2013 at 06:28 PM 1
Share

Yeah, but come now, all I do is ask for technical assistance, and they go all "HURR DURR SHUN THE SCRIPT-AS$$anonymous$$ER DERP LOL #WEWANNAABUSEOURPOWERS #YOLOSWAG BWAHAHAHAHA!" it's really frustrating at times to work with people doing that. I mean I was practically screa$$anonymous$$g at an ad$$anonymous$$ for closing my question when I was working under a deadline... Not cool...

avatar image DubstepDragon · Jul 22, 2013 at 07:43 PM 2
Share

Crap, looks like I uninstalled skype... I will add you as soon as it finishes installing. Who knows, maybe from time to time I will need assistance! Thanks dude!

Show more comments

2 Replies

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

Answer by clunk47 · Jun 12, 2013 at 08:24 PM

 PlayerPrefs.SetInt("Gold", goldAmount);

Check out the DOCS.

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
5

Answer by Lukas H · Jun 13, 2013 at 12:42 PM

And to retrieve it again do something like:

 private int goldAmount = 0;
 
 void Start()
 {
    goldAmount = PlayerPrefs.GetInt("Gold");
 }
Comment
Add comment · Show 1 · 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 DubstepDragon · Jul 22, 2013 at 06:14 PM 2
Share

Sweet, thx man!

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

16 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

Related Questions

A node in a childnode? 1 Answer

Want to make a JRPG. 1 Answer

How can I store a number larger than 2147483647 in PlayerPrefs? 3 Answers

Is it possible to use ToString to format a playerpref int value? (JS) 0 Answers

Can I call a js script method inside a C# dll project? 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