Question by 
               mullac51 · Feb 07, 2017 at 02:14 AM · 
                c#gameobjectmouseonmousedownclick objects  
              
 
              Disable mouse click on gameObject
I want to stop the player from being able to left click on the gameObject in c#
I have googled this and can't seem to find the answer
               Comment
              
 
               
              Answer by ionside · Feb 07, 2017 at 02:26 AM
There's quite a few options on how you can do this @mullac51. It depends on whether to want to allow the gameObject to be selectable again at some point. If not you could simply delete the collider on the object.
 Destroy(gameobject.collider);
 
               or just disable it.
 gameobject.collider.isTrigger = false;
 
               You could create a tag for the object and test against that flag. If the object's tag == 'ignore' than ignore.
 if(gameobject.tag == "ignore"){
 // Do nothing
 }
 else{
 // Do mouse click code
 }
 
               You can also test against Layers.
@mullac51 something like
 gameobject.GetComponent<Collider2D>().enabled = false;
                  Your answer