- Home /
How to change Texture of a character and keep animations
I would like to do the above but you can change the texture back with key 1 and change to differnent on key 2 and be able to switch back and forth. How can I do that? Thanks!
Answer by ExplodingCookie · Jun 22, 2013 at 07:24 PM
Use this in a script attached to your character's mesh
var mat1 : Material;
var mat2 : Material;
function Update () {
if(Input.GetKeyDown("1")) {
renderer.material = mat1;
} else if(Input.GetKeyDown("2")) {
renderer.material = mat2;
}
}
renderer links to the attached Mesh or Skinned Renderer. So you need to put this JavaScript onto the Mesh object for it to work. render.material is the first material on the renderer's list, if you have multiple materials that is a different story.
Glad to have been of assistance. Don't forget to click the check button underneath the thumbs to let other people know the problem has been solved.
~ExplodingCookie
Your answer
Follow this Question
Related Questions
Custom Pivot Points in Sprite Editor 1 Answer
Unity4.5 AnimationCurve - Is the property "_MainTex.rotation" valid ? 0 Answers
Looking for tutorial for door animation using mecanim 2 Answers
Converting legacy animation to mechanim 2 Answers
Set the procedural color texture script to a set pattern? 1 Answer