playMaker

Author Topic: How do you set material color of prefab?  (Read 2000 times)

wheretheidivides

  • Sr. Member
  • ****
  • Posts: 496
How do you set material color of prefab?
« on: April 05, 2015, 02:47:36 PM »
So I have a tank prefab with child objects.  They in turn have child objects which have materials.  I wish to change the color of the grandchildren and below.  In the project folder you can only see the parent and the 1st level child.  So you can't see the grandchild unless you put it in the hierarchy.  So how would you do this?

I want to change the color of the material of the grandchild to 0,200,0 (from the standard 150,150,150) which is green.  That way each player can have a different color when playing in team mode.
« Last Edit: April 05, 2015, 02:51:21 PM by wheretheidivides »

Splankton

  • Sr. Member
  • ****
  • Posts: 268
Re: How do you set material color of prefab?
« Reply #1 on: April 07, 2015, 12:17:29 PM »
You have to get a reference of the gameobjects that have the material you want to change.  So you could use find child to store the gameobject variable.  Now you have the reference,  you will be able to set the material color.  Hope that helps. 

wheretheidivides

  • Sr. Member
  • ****
  • Posts: 496
Re: How do you set material color of prefab?
« Reply #2 on: April 07, 2015, 01:23:21 PM »
I see.  Thanks.