Question by
OS13 · Feb 16, 2018 at 01:47 AM ·
arrayserializationexception
NullReferenceException with serialized array
Hello! I have a script with arrays of serialized objects like this:
[Serializable]
public class GenerationZones {public GeneratedObjecct []
GeneratedObjets = new GeneratedObjecct[100];
public int PositionX = -1;
public int PositionZ = -1;
public int State = 0;
public int GeneradedObj = 0;}
[HideInInspector]
public GenerationZones [] GenZones = new GenerationZones[100];
When i hit play in a scene where the script is working everything is ok. But when i hit play in another scene and then i enter a scene with this script, it's not working. On every call to GenZones[n] (or any another same element) the game throws 'NullReferenceException: Object reference not set to an instance of an object'.
What can be wrong?
Comment