Hi,
I have got a complex hierarchy of objects and I need to find all materials of all children and their children of a certain GameObject.
How can I achieve this?
Hi,
I have got a complex hierarchy of objects and I need to find all materials of all children and their children of a certain GameObject.
How can I achieve this?
GetComponentsInChildren()
You can then get the materials from the renderer"
http://unity3d.com/support/documentation/ScriptReference/Renderer.html
In case if somebody will need the code for this task:
private function GetAllMaterials(_parent : Transform) : Array
{
var allMaterials : Array = new Array();
for (var _renderer : Renderer in _parent.GetComponentsInChildren(Renderer) )
{
for (var _material : Material in _renderer.materials)
{
allMaterials.push(_material);
}
}
return allMaterials;
}