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
3
Question by ina · Nov 02, 2011 at 02:15 AM · playerprefsstringmaximum

Max size for PlayerPrefs.GetString or SetString ?

Is there a maximum length for the String you can store to PlayerPrefs?

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

3 Replies

· Add your reply
  • Sort: 
avatar image
5

Answer by scone · Apr 28, 2013 at 09:48 PM

So, I actually went and tested this. I found that in the editor, and in Windows builds, this breaks at a 1MB string. Oddly enough, on Android, it juts goes up till it crashes, but then every time I try to run it again, it crashes immediately.

using UnityEngine; using System.Collections;

public class PPDump : MonoBehaviour {

 public int length;
 public string original = "x";
 string str;
 public int count;
 public bool run;

 void Start() {
     count = 0;
     length = 0;
     str = original;
 }
 void OnGUI() {
     GUILayout.Label("Length: " + length);
 }
 void Update () {
     if(run) {
         str += str;
         length += str.Length;
         PlayerPrefs.SetString("save " + count, str);
         if(PlayerPrefs.GetString("save " + count) != str) {
             Debug.Log("Broken");
             run = false;
         }
         count++;
     }
 }

}

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
2

Answer by guavaman · Jul 28, 2014 at 01:13 AM

The size limit will depend on the platform. For example, on Windows standalone builds, PlayerPrefs uses the registry to store the values. According to Microsoft, the length limit of a registry value is 1MB. Registry Element Size Limits

So there is no fixed size limit set by Unity. You'd have to do testing to determine what the limit is on each platform.

FYI, Windows also has another little quirk when storing data in the registry. If your value name length (what Unity calls a key) is 255 characters or longer, the value will not show up in Regedit, though Unity will still load the value fine. Unity appends a 12 character suffix to whatever you name your key, so the max chars you can use without making the value invisible to Regedit is 243 characters.

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 _Petroz · Nov 02, 2011 at 02:26 AM

I don't think there is a maximum size per element but there is a maximum size for the total data (the smallest is webplayer which is 1MB).

http://answers.unity3d.com/questions/151948/how-many-variables-can-i-store-using-playerprefs.html

Comment
Add comment · Show 5 · 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 Bunny83 · Nov 02, 2011 at 04:02 AM 0
Share

The 1$$anonymous$$B limit does only exist in the webplayer. In standalone builds the playerprefs are stored in the windows-registry or as a seperate file on $$anonymous$$ac OS. For more information read the PlayerPrefs docs.

avatar image ina · Nov 02, 2011 at 04:09 AM 0
Share

Is there a limit for iOS or Android?

avatar image _Petroz · Nov 02, 2011 at 05:24 AM 0
Share

I thought the 1$$anonymous$$B limit might be specific to one platform, thanks for clearing that up.

avatar image ina · Jun 22, 2012 at 09:17 AM 0
Share

How do you try finding out the definitive max string size for mobile platforms

avatar image whydoidoit · Jun 22, 2012 at 09:44 AM 0
Share

I am informed that there is no limit (except for device memory) on mobile - Web is limited to 1$$anonymous$$B total size.

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 for saving strings 1 Answer

PlayerPrefs script problem 2 Answers

How to convert raw keycode to characters 1 Answer

PlayerPrefs from One App to Another. 1 Answer

PlayerPrefs Question 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