How to make a button to change the object texture?

Hi,

I’m trying to create a button or an input key which allow me to switch between 2 texture for the same object.One is suppose to be the default gray shader, the other is a jpg texture.

I’ve tried this but it juste make my object dissapeard:

  function Update (){ 
       if (Input.GetKeyDown(KeyCode.Space)){ 

             renderer.enable=!renderer.enabled;

     }
}

Can someone help me please? thanks in advance

Your code is just switching the renderer on and off. Try changing it’s texture instead.

If I translate your code in pseudo Code, it says :

“set the renderer’s enabled property to the opposite of the renderer’s enabled property” ( I guess you misspelled enabled, forgetting a d).