Search Unity

UI Button click event conflicts Input.GetMouseButtonDown(0) event

Discussion in 'UGUI & TextMesh Pro' started by deadwind88, Nov 17, 2014.

  1. deadwind88

    deadwind88

    Joined:
    Nov 17, 2014
    Posts:
    1
    Hi all
    I'm newbie.
    I want to create a game but i have a problem like post's title.
    I develop 2 feature
    - Click to screen to get mouse position and hit an object. I use Input.GetMouseButtonDown(0) and Raycast2D
    - Click a button to select an item. I use Unity 4.6 UI Button.
    But when i click the button, system calls both of 2 events, it calls Input.GetMouseButtonDown first then Buton click event second, so i can't use flag to fix conflict.

    Please tell me how can i ignore mousebuttondown when i click on UI button?
    I really need your help.

    Thanks so much.
     
  2. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    There are plenty of answers on how to solve this problem on the forums already. You need EventSystem.IsPointerOverEventSystemGameObject (i think thats the name)