This question was
closed May 08, 2018 at 08:08 AM by
tormentoarmagedoom for the following reason:
The question is answered, Answer is inside the question
Question by
NolanOc · May 05, 2018 at 07:43 PM ·
arrayloopfor-looparray of gameobjects
Same for each loop with multiple arrays?
Wasn't sure how to phrase my question but ill try to explain here a little better.
So I have a for each loop that goes through each item in multiple arrays of gameObjects and enables them.
foreach (GameObject go in Array1)
{
go.SetActive (true);
}
foreach (GameObject go in Array2)
{
go.SetActive (true);
}
foreach (GameObject go in Array3)
{
go.SetActive (true);
}
Since I am doing the same thing to each array is it possible to make this look a little nicer by doing something along the lines of
foreach (GameObject go in Array1, Array2, Array3)
{
go.SetActive (true):
}
It works fine just looking for a neater way to write this. Thanks!
Comment
Answer by tormentoarmagedoom · May 07, 2018 at 08:58 AM
I dont know if there is a C# way to write what you want, but what you can do is combine all 3 arrays in 1 big array, and then do the foreach.
Check this post to see how to do it.
Bye!