x


How to switch the texture being used by the material of the mesh renderer

When the level starts the player has to choose different parts of different animals. For example the head and body of a cat, the tail of a squirrel and the legs of a kangooroo. They'll see this in the UI that we built, but when the player presses play the appropriate model has to be built, according to his choices.

At first we wouldn't animate them, but maybe if we have time before the deadline we'd like to do something simple: a slight rotation around an anchor point at the top of the legs that makes them move back and forth. But nothing too complicated, it's meant to be a bit cartoony. It would be awesome if we could just get it to show the correct model, with the proper textures applied, so how do we switch do to use a different texture? :x

more ▼

asked Jan 07 '10 at 01:23 PM

VinDi gravatar image

VinDi
11 1 1 2

this should be renamed "Changing the used texture of the material on a mesh renderer."

Mar 11 '10 at 05:42 PM Scott 4
(comments are locked)
10|3000 characters needed characters left

1 answer: sort newest

Simply this, if your script is placed on the gameobject whose texture you want to change:

renderer.material.mainTexture = yourNewTexture;
more ▼

answered Jan 07 '10 at 04:02 PM

duck gravatar image

duck ♦♦
41k 92 148 415

(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:

x2203
x1363
x815
x379
x275

asked: Jan 07 '10 at 01:23 PM

Seen: 3557 times

Last Updated: Apr 16 '10 at 03:03 PM