Getting the element that has the same element number on another list ?
Simple question:
if I have two lists (string list And text list) how can I make every text in List1 to get his twin in List2 ?
.
without typing
List1 [0].text = List2 [0]
List1 [1].text = List2 [1]
List1 [2].text = List2 [2]
.
just telling every text inside the list to get any string has the same element number of him ?
Answer by SteenPetersen · Aug 12, 2017 at 12:01 PM
for (var i = 0; i < List1.Count; i++) {
i.text = list2[i];
}
untested but I think that this sort of logic should work, at least a starting point.
Thank you! I face some errors with your script but it fixed this is the fixed version
for (var i = 0; i < List2.Count; i++) {
List1[i].GetComponent<Text>().text = List2[i].ToString();
}
ahh nice yea, was answering that question at work didnt have unity infront of me =)
Answer by Chino_96 · Aug 25, 2017 at 12:56 PM
What if a have a List string and a List GameObject? how can I adapt this to my needs? @Vadol @SteenPetersen