tranparent object

there is a way to create a touch button, on touch the 3d object get 50% transparence and touch again the 3d object came back to normal.

Something like that?

public class Button : MonoBehaviour 
{ 

  // the material of the object you want to make transparent      
  public Material objectMaterial;

  private void OnGUI() 
  { 
    if( GUILayout.Button( "Touch" ) ) 
    { 
      var color = objectMaterial.color;
      if( color.a <= 0.5f ) 
        color.a = 1;
      else 
        color.a = 0.5f

      objectMaterial.color = color;

     }

}