- Home /
Saving values generated in game to use in prefabs.
I have made a random tiled background generator that generates a bidimensional array of ints, each one representing 1 tile of the background. Works great and generates good maps, but since some specific events must happen in specific tiles (and I don't want them to be random), I must save those maps somewhere to know the location of those tiles beforehand and work with them.
Usually, when saving a prefab, the values of the variables are stored with it, but it doesnt seem to happen for variables which do no appear in the inspector.
The array is defined as:
public static int sizeY = 10000;
public static int sizeX = 7;
public int[,] map = new int[sizeX,sizeY];
¿Any ideas of how can I save this bidimensional array of ints for modification in the inspector?
Answer by tomka · Jun 08, 2012 at 07:14 AM
You can instruct private fields to be serialized.
see http://unity3d.com/support/documentation/ScriptReference/SerializeField for how to do this.
Answer by ArturoFBC · Jun 08, 2012 at 04:14 PM
Serialize the field or the class won't get those variables to show. I think thats because I am using arrays of static size.
Is there any other way to create a bidimensional array of fixed size than to declare it with static int sizes?
Your answer
Follow this Question
Related Questions
Array value not changing? 1 Answer
assign string value from array to multiple game objects 1 Answer
Acessing array / list from Gizmos in editor 1 Answer
Enum drop down menu in inspector for nested arrays 2 Answers
Why can't I access the Name field in the Custom Styles section of a GUISkin in the Inspector? 2 Answers