Hello! I was just wondering if it is possible to make-
`array[0,2,3,4,5,6,7,8,9,10]`
into something shorter (of-couse scripting this isn't a pain but, with alot more it is), or at least how to access the renderers of children of a transform.
Hello! I was just wondering if it is possible to make-
`array[0,2,3,4,5,6,7,8,9,10]`
into something shorter (of-couse scripting this isn't a pain but, with alot more it is), or at least how to access the renderers of children of a transform.
var arr : Array;
function Start () {
arr.Add(0); //adds the first value in your array
for(i=2;i<11;i++) arr.Add(i); //adds 2, 3, ... 10
}
This script is untested, but I think you get the idea. Using for() you can easily add several values to an array. Also look at GetComponentsInChildren(). This will get all the components of the type of the Children and the gameobject itself. I for instance use this script
function SetLinerenderer () {
linerenderer = linerendererContainer.GetComponentsInChildren(Transform);
linerenderer.Shift();
}
This will add the transform of all children of the gameobject calledlinerendererContainer + the transform of the container. The order of the array will be: the transform of the container and then the alphabetical order of the children. So add 1,2,3 to the names of the children to get the order right. Also remember to use .Shift() to remove the transform of the gameobject itself.