Array.length for ScriptableObject exploded in build
I'm wondering what could change the size of an array in a scriptableObject in a build.
I was getting a nullreferenceexception in my build and I traced it back to an array whose length somehow changed from 77 to 6619237. Since that is a static array that is saved in a scriptableObject, and I don't have any code that changes it at runtime, I'm wondering what else might cause it to go wild.
I do load and save the scriptable object, containing the array, but I never change the array (to my knowledge). So maybe it's something in the json serialization/deserialization for arrays inside scriptableObjects that goes bonkers???
Answer by Livealot · Dec 01, 2018 at 03:07 PM
Two things, serialization for arrays wasn't working...across builds
First, having an array in the ScriptableObject causes a lot more headaches in serialization/deserialization than a list
Second, the reference to my ScriptableObject with an array was on another ScriptableObject, and I'm guessing the hash reference behind the scenes didn't match from build to build. Within the same build worked fine which is why there was no issues in development, but comparing saved files from old builds to the new build was a problem, leading to a bad array.