Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Apply a script to the children of a GameObject?

Discussion in 'Scripting' started by bloxybox, Feb 2, 2015.

  1. bloxybox

    bloxybox

    Joined:
    Jan 11, 2015
    Posts:
    3
    Hello! This is my first thread on the Unity forums, and I just wanted to ask a question. I have an Empty GameObject which consists of many cubes, and I want to go into the GameObject and change all of the Children with one script, because I know there is a better way than applying this script to all of the objects:

    gameObject.renderer.material.color = Color.white;

    Is this possible? If so, can I get a small example script or a reference that shows me how to do this?

    Thanks a lot!
     
  2. fire7side

    fire7side

    Joined:
    Oct 15, 2012
    Posts:
    1,819
  3. bloxybox

    bloxybox

    Joined:
    Jan 11, 2015
    Posts:
    3