2016-10-21 28 views
0
public void application() // function when the mouse only find the ui canvas button 
{ 
    // when the mouse find only canvas button and when clicked then do something else stop 

    if (Input.GetButton("Fire1")) 
    { 
     print("button pressed"); 
    } 
    else { 
     print("button released"); 
    } 
} 
+1

GetbuttonDown和getbutton起來,而不是getbutton應該工作 –

+0

不工作,他們的返回類型完全改變... – Muhammad

回答

1

當UI系統打交道時,你應該使用IPointerXXXX接口:

public class MyClass: MonoBehaviour, IPointerUpHandler{ 

    public void OnPointerUp(PointerEventData eventData) 
    { 
     throw new NotImplementedException(); 
    } 
} 
相關問題