- Home /
Creating Arrays
Hi, all! I am currently far into the process of creating my third complete game with Unity, and for once this one isn't as simplistic ;) There are 3 save slots, and 3 of each variable need for the game (One for each slot). For instance, Foo1 would be Slot 1, Foo2 would be Slot 2, and Foo3 would be Slot 3.
I have a bunch of variables that I need to save at the end of every round. I thought it would be nicer to stuff all of my variables into their respective arrays (For reference and for changing them easily) and then stuffing those arrays into a giant array called AllData (so that I can just be like Save(AllData)). All these variables are in one giant script named 'Master'.
So if I want to change Foo in Slot 1 I can now go Master.Foo[1] = 24.5;
What I am wondering here is if it is better to go:
var Foo1 : int;
var Foo2 : int;
var Foo3 : int;
var Foos = new Array(Foo1, Foo2, Foo3);
var Alldata = new Array[[Foos],[Foobars],[BarFoos]];
or is it better to go:
var AllData : int[,]
var Foos : int[] = new int[3];
AllData [0,0] = Foos[0]
AllData [0,1] = Foos[1]
AllData [0,2] = Foos[2]
OR us it better to go:
So I mean is it better to declare variables before if I know that when the variables are declared they will simply be empty?
And then would it be better to just go with the second example and use comments in the script for me to keep track of everything?
Thanks for your patience! ^^- YA
Your answer
Follow this Question
Related Questions
Distributing codes that have dependencies with other assets 1 Answer
How to play several audio cllips one after another. 3 Answers
Check if all Materials are generated? 0 Answers
It's possible to uninstall a game via code (C#)? 2 Answers
Im having trouble with my Audio playing on a Mouse Click. Tell me what is wrong with my Script? 2 Answers