private var story1 : String;
private var story2 : String;
private var story3 : String;
private var story4 : String;
private var story5 : String;
private var story6 : String;
private var story7 : String;
private var story8 : String;
private var story9 : String;
private var story : String[] = new String[9];
private var i : int;
function Awake() {
for(i=0;i<9;i++) {
story *= story+i;*
} } I want to store the string variables in this array. How can I do this??
It may be slower but have you considered using array.Push(variable) instead?
Example: Untested
private var story1 : String;
private var story2 : String;
private var story3 : String;
private var story4 : String;
private var story5 : String;
private var story6 : String;
private var story7 : String;
private var story8 : String;
private var story9 : String;
private var story : Array = new Array();
private var i : float = 0;
function Awake() {
for(i=0;i<9;i++) {
story.Push(story+i);
}
Debug.Log("Values within the story() array are: "+story);
}
Edit: Actually, now that I think of it, I don’t believe “story+i” will produce “story1”, “story2” etc, but I’m not sure. If you get around that I believe the code above will work for you.