当按住ui画布按钮时,按下鼠标按下时做一些事情

时间:2016-10-21 05:16:53

标签: c# canvas unity3d

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 个答案:

答案 0 :(得分:1)

在处理UI系统时,您应该使用IPointerXXXX接口:

public class MyClass: MonoBehaviour, IPointerUpHandler{

    public void OnPointerUp(PointerEventData eventData)
    {
        throw new NotImplementedException();
    }
}