Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
This question was closed Dec 24, 2016 at 08:07 PM by TinoClemente for the following reason:

Problem is not reproducible or outdated

avatar image
0
Question by TinoClemente · Dec 18, 2016 at 02:37 PM · arrayserializationsize

Change serialized array size

alt text

Hi, i have a problem with my serializable class. The array "usable" was a 13 elements array in the past, now I've changed its size to 14. But i'm unable to play the game, because in the saved data the array has the size of 13 elements. If I delete the player data on my PC it works, but in android I can't do that on all the users phones! Please help me.

capture.png (8.3 kB)
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

1 Reply

  • Sort: 
avatar image
0

Answer by Adam-Mechtley · Dec 19, 2016 at 08:18 AM

If you are just populating this field at run-time, then I would mark it with System.NonSerializedAttribute or similar. If you do in fact have actual data saved in this field in assets, you could copy and resize this field in OnEnable () or ISerializationCallbackReceiver.OnAfterDeserialize (), though the better option would be to write some kind of editor script that updates all of your prefabs offline.

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 TinoClemente · Dec 21, 2016 at 04:37 AM 0
Share

Hi Adam! Thanks for your respond. I use the array "usable" to know witch characters have the player unlocked, I load and save data on it. $$anonymous$$y game's users have already a file on their phones with this structure, and now I want to change this array size. Unity has a script that lets you change a serialized field's name, but they are any help to change an array size :(

avatar image TinoClemente · Dec 21, 2016 at 04:38 AM 0
Share

I think that if I change the array size in OnEnable(), maybe the problem stills there, because the user has this array on the persistance data file with 13 elements.

avatar image Adam-Mechtley TinoClemente · Dec 21, 2016 at 08:05 AM 0
Share

I don't know how you're storing this persistent data on the user's device, but the idea here is you are just checking its length when you deserialize. If it is too short, you increase the length of the deserialized array and re-serialize and save the data on the device as needed.

Follow this Question

Answers Answers and Comments

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

Related Questions

Why do Constructors return null when used within EditorWindow 1 Answer

Best way to serialize a big array of a class 2 Answers

JsonUtility and Arrays - JSON must represent an object type. 0 Answers

Array of custom classes not saving to Playmode 0 Answers

Unity custom class array serialization issue. 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