• 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
Question by greatwhiteshark17283 · Mar 27, 2015 at 10:29 PM · arrayplayerprefssaveplayerprefsxarrayprefs

How to save an array to PlayerPrefs?

I know about PlayerPrefsX (http://wiki.unity3d.com/index.php/ArrayPrefs2) but I don't know how to save somet$$anonymous$$ng like t$$anonymous$$s to it:

 var storage = new Array("box", "table", "chair");

Whenever I try PlayerPrefsX.SetStringArray, I get errors. I tried just PlayerPrefsX.SetArray, but that didn't work either. Is there a way to save an array like t$$anonymous$$s?

Comment

People who like this

0 Show 4
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 siaran · Mar 27, 2015 at 11:18 PM 0
Share

"I get errors" is remarkably uninformative. Please be a little more specific?

Alternatively, you can use serialization instead of PlayerPrefs to store your data. Here is a good tutorial on save/loading in Unity: http://gamedevelopment.tutsplus.com/tutorials/how-to-save-and-load-your-players-progress-in-unity--cms-20934

(in C# rather than javascript, but you should use c# instead of javascript anyway. :P I don't know how serialization works in javascript. )

avatar image greatwhiteshark17283 · Mar 27, 2015 at 11:39 PM 0
Share

The errors are "The best overload method" for SetStringArray and "Missing Exception" for SetArray

avatar image NoseKills · Mar 27, 2015 at 11:45 PM 0
Share

Come on... please copy paste the errors and the lines that cause them here. A doctor can't help you if you go to him and just say "it hurts".

avatar image greatwhiteshark17283 · Mar 27, 2015 at 11:56 PM 0
Share

Assets/Custom Assets/Scripts/Stats.js(69,36): BCE0017: The best overload for the method 'PlayerPrefsX.SetStringArray(String, String[])' is not compatible with the argument list '(String, Array)'. That's for the SetStringArray MissingMethodException: PlayerPrefsX.SetArray Boo.Lang.Runtime.DynamicDispatching.MethodDispatcherFactory.ProduceExtensionDispatcher () Boo.Lang.Runtime.DynamicDispatching.MethodDispatcherFactory.Create () Boo.Lang.Runtime.RuntimeServices.DoCreateMethodDispatcher (System.Object target, System.Type targetType, System.String name, System.Object[] args) Boo.Lang.Runtime.RuntimeServices.CreateMethodDispatcher (System.Object target, System.String name, System.Object[] args) Boo.Lang.Runtime.RuntimeServices+c_AnonStorey15.m_9 () That's for SetArray

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by sprawww · Mar 28, 2015 at 12:06 AM

I don't really know JS/US, but t$$anonymous$$s should be correct:

 var storage = ["box", "table", "chair"];
 PlayerPrefsX.SetStringArray ("Storage", storage);

Just to be safe, the C# Version:

 var storage = new string[] { "box", "table", "chair" };
 PlayerPrefsX.SetStringArray ("Storage", storage);
Comment
greatwhiteshark17283
guetta18
Cloner_ES
SukalyanMajumdar

People who like this

4 Show 3 · 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 greatwhiteshark17283 · Mar 28, 2015 at 01:39 AM 1
Share

Thank you so much! The JavaScript works perfect!

avatar image muhammadtahiriqbal · Aug 10, 2015 at 03:25 PM 2
Share

the playerprefsx is not show in my monodeve

avatar image guetta18 muhammadtahiriqbal · Dec 06, 2018 at 12:01 PM 0
Share

you have the class in the link. scroll little bit down you will see it - there is both js and c#.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

25 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Saving Array Objects in Android. 0 Answers

How to Get a PlayerPrefsX boolean? 1 Answer

I cannot store data into PlayerPrefs after a certain amount of data 2 Answers

Attempting to store an Inventory Array in PlayerPrefsX 1 Answer

Help with Saving ArrayPrefs 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