- Home /
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
this should be renamed "Changing the used texture of the material on a mesh renderer."
Answer by duck · Jan 07, 2010 at 04:02 PM
Simply this, if your script is placed on the gameobject whose texture you want to change:
renderer.material.mainTexture = yourNewTexture;
Your answer
Follow this Question
Related Questions
How can i change detail texture? 1 Answer
Why are my textures on planes flipped / reversed left-to-right? 1 Answer
Changing two different objects renderer colour 1 Answer
Swapping out materials on a skinned mesh renderer? 3 Answers
How to switch texture of several 3D objects on GUI buttons click? 1 Answer