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 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 something like this 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 this?

Comment
Add comment · 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 ins$$anonymous$$d 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# ins$$anonymous$$d 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 "$$anonymous$$issing 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 $$anonymous$$issing$$anonymous$$ethodException: PlayerPrefsX.SetArray Boo.Lang.Runtime.DynamicDispatching.$$anonymous$$ethodDispatcherFactory.ProduceExtensionDispatcher () Boo.Lang.Runtime.DynamicDispatching.$$anonymous$$ethodDispatcherFactory.Create () Boo.Lang.Runtime.RuntimeServices.DoCreate$$anonymous$$ethodDispatcher (System.Object target, System.Type targetType, System.String name, System.Object[] args) Boo.Lang.Runtime.RuntimeServices.Create$$anonymous$$ethodDispatcher (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
4
Best Answer

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

I don't really know JS/US, but this 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
Add comment · 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.

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

PlayerPrefsX plugin error when build for windows store 3 Answers

How do I save a three dimensional array? 1 Answer

bool array to playerprefs 1 Answer

assigning arrays with for in 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