I have a series of objects laid out in a grid and I want to select one of these objects at random and change their colour. In the hierarchy the objects are laid out like this:

city
-Line 1
  -Building 1
  -Building 2
  -Building 3
  ...
  -Building 23
-Line 2
  ...
-Line 23

So each line has 23 buildings and there are 23 lines. I want to produce two random numbers, x and y, then I want to go to line x and building y in that line and change the colour of that object. So I have two queries. Firstly how do you change the colour of an object and secondly how I traverse the hierarchy and access a child of a parent?
Thanks

Try this:

for (var child : Transform in transform) {
    var RandomColor = Color(Random.Range(0.0f,1.0f),Random.Range(0.0f,1.0f),Random.Range(0.0f,1.0f));
    child.renderer.material.color = RandomColor;
}

The real problem is that, even though you’ve written it as two Q’s, in your mind it’s still one Q. So you can’t focus on each Q by itself.

You can easily look up how to find a child object. It’s transform.Find and there are plenty of examples.

And, you know you can look up how to change color. It depends on the exact material and shader. But generally just B.renderer.material.color (where B is whatever object.)