Input.GetMouseButton gets buffered and causes problems

Hi, I’m using Input.GetMouseButton(0) as a condition for an if block. It works fine but when I click on the taskbar or on another application window (e.g. a yahoo messenger window), or anywhere outside the unity screen, the Input.GetMouseButton(0) becomes true and stays true until i click again. That is,

  1. i click outside the unity screen
  2. i hover over the unity screen without pressing on the mouse buttons
  3. But Input.GetMouseButton returns true.

Thanks

Its because the window has lost focus. I havent used the PC version of Unity but there is a method called OnApplicationPause() where you should tell this script to stop processing mouse input until it has focus again.