Search Unity

Input.GetMouseButton gets buffered and causes problems

Discussion in 'Scripting' started by April, Nov 3, 2010.

  1. April

    April

    Joined:
    Dec 14, 2009
    Posts:
    62
    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
     
  2. FluidPixel_Gavin

    FluidPixel_Gavin

    Joined:
    Jan 6, 2010
    Posts:
    88
    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.