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 Alessandro · Apr 07, 2011 at 08:14 PM · iphoneoptimizationplayerprefsspeed

Is "PlayerPrefs" (Get/Set) slow ?

I need to pass some variables (lets say 30 or 40, mostly Int) from one script to another. But not just on "Start", but whenever the user hits a "Menu" button.

I could use PlayerPrefs.SetInt and PlayerPrefs.GetInt to write/read those variables or thatd be too slow comparing to the usual method of passing parameters (lets say fill an array with those ints or something and pass it to the other script when the user hits the "Menu" btn) ??

I dont actually NEED these data to be persistent, but you never know..... if the two approaches are similar regarding the speed, Ill prefer the PlayerPrefs road..

Thks in advance!

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

2 Replies

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

Answer by xCRKx TyPHooN · Apr 07, 2011 at 09:36 PM

Unless you are having some issues with speed, I wouldn't even worry about it. If it's just menus where you need to pass parameters like this I see no reason why you can't use the Get() and Set() functions. The function itself may be "slow" in a continuous update loop, but for a one time click event it should be fine.

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 Joshua · Apr 08, 2011 at 12:44 AM 0
Share

Yep, definitely the correct answer.

avatar image
0

Answer by esdin · Jul 30, 2011 at 09:29 PM

There is a currently existing bug where activating the Keyboard view in Unity iOS applications can result in a severe increase in PlayerPrefs write times.

In general, you can optimize your PlayerPrefs call by writing to your own hashtable and then loading and flushing all values from device playerprefs at application launch and quit.

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 esdin · Jul 31, 2011 at 02:48 AM 0
Share

Here's an excellent post with a PlayerPrefs override class you can add to plugins. While the class included may not be the perfect fit for your project, it is definitely a good example to start from. http://www.previewlabs.com/writing-playerprefs-fast/

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

(2 hidden skinned meshes) or (1 extra draw call) for character props? 2 Answers

Loading a prefab over multiple frames. 1 Answer

Does anyone know why continuously saving to playerprefs would cause a performance drop ? 0 Answers

Game build works fine in Android but is jittery in iPhone. 0 Answers

Increase in speed in iPhone Advanced 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