I have an array of objects, a custom class that has an attribute called ‘commentUID.’ I’m trying to output a string that combines the commentUID of each object with a comma in between. However, my script won’t add anything past the first object, and I have no idea why. It’s running through the loop…it’s just not adding the commentUID strings. If I try it with another type of object, like have it add a simple string, it works as expected. Any ideas?
var allComments : commentObj[] = new commentObj[0];
class commentObj {
//Use this number to assign the Alr
private var projectID : int = 1;
var commentUID : String;
var user : userInfo;
var userPos : userPosition;
var target : GameObject;
var targetPosition : Vector3;
var view : Texture2D;
var date : System.DateTime = System.DateTime.Now;
var text : String;
}
var CommentString : String;
for (var x = 0; x<allComments.Length; x++){
if(x == 0){
CommentString = allComments[x].commentUID;
Debug.Log("Ran Once");
}
else{
CommentString = CommentString + "," + allComments[x].commentUID;
Debug.Log("Ran " + (x+1) + " times");
}
}