I wrote some code with foreach loop but it looks very ugly and I wanna translate it into LINQ version but i can't figure out how to do that (sorry, I am new to LINQ) and can someone tell me the LINQ way of my code which is given below?
GameObject[] everything = Resources.FindObjectsOfTypeAll(
typeof(GameObject)) as GameObject[];
GameObject layoutContainer = new GameObject();
foreach (GameObject obj in everything) {
if(obj.name == "LayoutContainer") {
layoutContainer = obj;
break;
}
}
FirstOrDefaultmethod. Something likelayoutContainer = everything.FirstOrDefault(obj => obj.name == "LayoutContainer")