Answer about mainTexture

When i have two meshes renderers as child of a empty object, how to define the main object with the mainTexture, when i call `renderer.material.mainTexture` ( the script is attached in the parent object).

alt text

I'd like the object "Top" has the mainTexture. The mesh is exported from 3ds Max (fbx). Can anyone help me?

If it's attached to the parent you can address a specific gameobject using either way:

1.If children are already there before running the game you can simply define a gameobject variable and assign the child to it.

var top:GameObject;

top.renderer.material.mainTexture = ....;

2.Use this way if your children are dynamically being added or removed and also if you know their names.

var top:GameObject = transform.Find("top").gameObject;
top.renderer.material.mainTexture = ....;