I got a problem in my project. I want to know that mouse cliked happend on GUI or on any game object. I have tried this but it is showing null reference exception
Finally got my answer here: There are three ways to do this, as demonstrated in this video tutorial. this video save me:).
Use EventSystem.current.IsPointerOverGameObject
Convert your OnMouseXXX and Raycasts to an EventSystem trigger. Use a physics raycaster on the camera
Implement the various handler interfaces from the EventSystems namespace. Use a physics raycaster on the camera.