- Home /
 
 
               Question by 
               sailesh · Apr 23, 2014 at 06:24 PM · 
                textureing  
              
 
              How to change 2d texture when I press a button
 public Vector2 jumpforce = new Vector2(0,300);
 
 public Texture tex1;
 
 bool fixedAngle;
     
     void FixedUpdate () {
     
 if (Input.GetKeyDown (KeyCode.UpArrow)) {
 
             rigidbody2D.velocity=Vector2.zero;
             rigidbody2D.AddForce(jumpforce*1000);
             }
     if(Input.GetKeyDown(KeyCode.DownArrow)){
             renderer.material.mainTexture=tex1;
         }
 }
 
               When I try this code, Player character not changing to the defined texture for DownArrow. Please Help me!
               Comment
              
 
               
              Does your renderer have multiple materials? Can I see the code that loads "tex1" and also a screenshot of your renderer materials list?
Your answer