renderer.material = transform.parent.renderer.material;
This line of code provided by [robertbu][1] as a commentary does exactly what I wanted without dealing with getcomponentinparent stuff.
[1]: http://answers.unity3d.com/users/16320/robertbu.html
↧