I have a Class which contains multiple variables that are set at Start(). Start() Contains a loop to set those variables multiple times from an array. So… this is my code currently
for (var x=0; x<gameCount; x++){
var num : int;
var dataArr = new Array();
var d = ""+gameArray[x];
dataArr = d.Split(":"[0]);
// Debug.Log("ToString Data: " + d);
// Debug.Log("dataArr Data; " + dataArr);
var data = new game();
data.id = int.Parse(dataArr[0]);
data.turn = int.Parse(dataArr[1]);
data.user1 = int.Parse(dataArr[2]);
data.user2 = int.Parse(dataArr[3]);
data.base1 = dataArr[4];
data.base2 = dataArr[5];
// Debug.Log(data.user1+" vs "+data.user2);
gameArray[x] = game;
// Debug.Log("From gameList " + data.id);
}
}
public class game extends MonoBehaviour{
var id : int;
var turn : int;
var user1 : int;
var user2 : int;
var base1 : String;
var base2 : String;
}
As you can see, I put in plenty of debugs in there to help me out. Everthing here works. I can even debug the variables from this class and I get the needed values. My biggest problem is that I can not seem to figure out how to properly access these from another script. Am I gonna have to set more then one class for every irritation of that loop? The idea behind this process was so I can do a loop somewhere else to get what I need out of that array. I was attempting to do ‘game.gameArray.id’ and so on. Obviously it was telling me gameArray was not part of class ‘game’. So… what is the right way of doing this??