x


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?

more ▼

asked May 15 '11 at 12:34 PM

drigobarros gravatar image

drigobarros
104 4 6 9

(comments are locked)
10|3000 characters needed characters left

1 answer: sort newest

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 = ....;
more ▼

answered May 15 '11 at 01:19 PM

Kourosh gravatar image

Kourosh
1.5k 47 53 65

I need to do this dynamically, and this solution works perfectly, thanks!

May 15 '11 at 03:20 PM drigobarros
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x414
x276
x8
x2

asked: May 15 '11 at 12:34 PM

Seen: 853 times

Last Updated: May 15 '11 at 12:34 PM