- Home /
Question by
Durgal · Mar 28, 2017 at 07:08 AM ·
colorcolor changeparent-child
Change Color of Children Based on Parent
I'm trying to set the color of a child object based on it's parent. I'd like to set the color when the child is created, inside the child object.
Here's what I have so far...
void Start ()
{
parentColor = this.GetComponentInParent<Renderer>().material.color;
GetComponent<Renderer>().material.color = parentColor;
}
I'm able to set the color of the object by changing parentColor to something like Color.cyan -- so I think I'm just not getting the color of the parent correctly. Any insight on a solution would be greatly appreciated.
Durgal
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612113916im_/https://answers.unity.com/themes/thub/images/avi.jpg)