all parents of a transform

i want to chance the material color the parents of a transform. what is i need to use on for

1 Answer

1

this should do it (should be valid in js and c#)

var currentParent = transform.parent;
while(currentParent != null)
{
    var parentRenderer = currentParent.renderer;
    if (parentRenderer != null)
    {
        //do something with parentRenderer
    }
    currentParent = currentParent.parent;
}

currentParent is not stable. i made with for(var parents:Transform.... but i cannot reach the children's parents. I need to make change color of all parents,childrens...

What's the problem with it? That should change all parents when you call it (you shouldn't be storing currentParent anywhere)

when i use your code , nothing happens , that cannot see the parents