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

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.


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
// Do mouse click code

You can also test against Layers.