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 IllogicalGames · Oct 02, 2014 at 11:17 AM · arrayplayerprefswindows store appplayerprefsx

PlayerPrefsX plugin error when build for windows store

Hi, im using playerprefsX plugin by wiki.unity3d.com to store my Arrays. it worked perfectly on any other platform including ios, and windows phone 8, but when im trying to build for windows store, i encounter this error:

Assets\Plugins\PlayerPrefsX.cs(213,9): error CS1061: 'System.Collections.BitArray' does not contain a definition for 'CopyTo' and no extension method 'CopyTo' accepting a first argument of type 'System.Collections.BitArray' could be found (are you missing a using directive or an assembly reference?)

and

 Assets\Plugins\PlayerPrefsX.cs(212,34): error CS1061: 'System.Collections.BitArray' does not contain a definition for 'Count' and no extension method 'Count' accepting a first argument of type 'System.Collections.BitArray' could be found (are you missing a using directive or an assembly reference?)
 

Comment
Add comment · Show 6
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 IllogicalGames · Oct 09, 2014 at 02:08 PM 0
Share

im new with program$$anonymous$$g and i have no idea what happens. in monodevelop there was no error and i can hit play, i even can run it on windows phone 8.0. but when i change platform to wsa 8.1, this error occur. doesnt make sense because it worked fine in wp8.0

avatar image IllogicalGames · Oct 09, 2014 at 02:10 PM 0
Share

it occur when im hit build or build and run

avatar image Bunny83 · Oct 09, 2014 at 04:21 PM 0
Share

Are you sure you use this version:

http://wiki.unity3d.com/index.php/ArrayPrefs

Line 212 / 213 are inside SetStringArray and there isn't any use of BitArray class. You should link the actual source which you are using. We're not here to guess what scripts you're using.

avatar image IllogicalGames · Oct 19, 2014 at 02:12 PM 0
Share

sorry, the script that i was using is from here ArrayPrefs2

avatar image squareorb · Apr 28, 2015 at 03:34 PM 0
Share

Does anyone have a solution for this? I've also been using this script on Android and iOS with no problems. Now I'm building for Windows Store and getting the same error.

Show more comments

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Bunny83 · Apr 28, 2015 at 04:30 PM

It seems that the BitArray class, used to store a bool array in the PlayerPrefs, isn't fully supported on WS.

I haven't tested this yet, but it should work the same as the original methods. edit
Just cross-tested it (saving with the old method loading with the new and reverse) and it seems to work properly (tested with two different 10 item bool arraya). So it should be 100% compatible with data that has been stored with the old version.

I can't test it in a Windows Store project, so feel free to test it and give feedback if you get errors or if it doesn't work as it should.

Just replace those two methods in the "PlayerPrefsX.cs". I only created a C# version ^^ If someone is willing to create

 public static bool SetBoolArray(String key, bool[] boolArray)
 {
     // Make a byte array that's a multiple of 8 in length, plus 5 bytes to store the number of entries as an int32 (+ identifier)
     // We have to store the number of entries, since the boolArray length might not be a multiple of 8, so there could be some padded zeroes
     var bytes = new byte[(boolArray.Length + 7) / 8 + 5];
     bytes[0] = System.Convert.ToByte(ArrayType.Bool);    // Identifier
     int mask = 1;
     int targetIndex = 5;
     for(int i = 0; i < boolArray.Length; i++)
     {
         if (boolArray[i])
             bytes[targetIndex] |= (byte)mask;
         mask <<= 1;
         if (mask > 128)
         {
             mask = 1;
             targetIndex++;
         }
     }
     Initialize();
     ConvertInt32ToBytes(boolArray.Length, bytes); // The number of entries in the boolArray goes in the first 4 bytes

     return SaveBytes(key, bytes);
 }

 public static bool[] GetBoolArray(String key)
 {
     if (PlayerPrefs.HasKey(key))
     {
         var bytes = System.Convert.FromBase64String(PlayerPrefs.GetString(key));
         if (bytes.Length < 5)
         {
             Debug.LogError("Corrupt preference file for " + key);
             return new bool[0];
         }
         if ((ArrayType)bytes[0] != ArrayType.Bool)
         {
             Debug.LogError(key + " is not a boolean array");
             return new bool[0];
         }
         Initialize();

         int count = ConvertBytesToInt32(bytes);
         var boolArray = new bool[count];
         int mask = 1;
         int targetIndex = 5;
         for (int i = 0; i < boolArray.Length; i++)
         {
             boolArray[i] = (bytes[targetIndex] & (byte)mask) != 0;
             mask <<= 1;
             if (mask > 128)
             {
                 mask = 1;
                 targetIndex++;
             }
         }
         return boolArray;
     }
     return new bool[0];
 }

I've put the fixed script on my dropbox for the time being.

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 unimechanic · Oct 09, 2014 at 03:01 PM

According to the page that script is obsolete, and it was developed for WebPlayer:

This script has been made obsolete by Unity 2.1; PlayerPrefs now works in Web players.

http://wiki.unity3d.com/index.php/PlayerPrefsx

Use the actual PlayerPrefs instead:

http://docs.unity3d.com/ScriptReference/PlayerPrefs.html

Comment
Add comment · Show 2 · 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 IllogicalGames · Oct 09, 2014 at 03:50 PM 0
Share

Hi, thanks for the reply. Yes, the script is obsolete and then someone posted anew version called arrayprefs2. This is the one that i was using. It worked for all platform except windows store app.

avatar image Eric5h5 · Oct 09, 2014 at 05:01 PM 0
Share

@unimechanic: the page being discussed in this question is http://wiki.unity3d.com/index.php/ArrayPrefs2

avatar image
0

Answer by brucelam · Jun 24, 2018 at 05:08 AM

((ICollection)myArray).CopyTo

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

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

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

Related Questions

Attempting to store an Inventory Array in PlayerPrefsX 1 Answer

How to save an array to PlayerPrefs? 1 Answer

assigning arrays with for in 1 Answer

For In Loop Fills all values in arrays problem 2 Answers

Saving Array Objects in Android. 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