how to assign name to gameobject list from string list ?
public List namelist = new List(); private List cubelist = new List(); void Start () { for (int y = 0; y < 3; y++) { for (int x = 0; x < 4; x++) { GameObject cu = Instantiate(Cube, new Vector3(x, y, 0), Quaternion.identity); cubelist.Add(cu);
} }
}
// if my namelist list have [apple,banana,orange,peach,stawberry,grapes] i want to assign one fruit name to two of cubelist elements for example cublist[1,2].name = "apple" cublist[3,4].name = "banana" cublist[5,6].name = "peach" cublist[7,8].name = "stawberry" cublist[9,10].name = "orange" cublist[1,2].name = "grapes"
Your answer
![](https://koobas.hobune.stream/wayback/20220612131556im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Cant figure out how to implement a inventory system 1 Answer
Simple way to access data of different types within a nested array? 0 Answers
Destroy GameObject after certain amount is reached? 1 Answer
Remove connection between lists or arrays 3 Answers
Building tycoon game, need help storing variables into an array. 1 Answer