这里我有一些代码,我试图用OnMouseDown()
函数拖动对象。我尝试下面的代码但是没有用。我有2Dcircle collider
的2D对象。这个2D圆形对撞机无法检测OnMouseDown()
。如果没有在其他屏幕/摄像机屏幕上点击对象,我想检测鼠标点击。
这是我的小代码。
public void OnMouseDown()
{
spring.enabled = false;
clickedOn = true;
Debug.Log (this.gameObject.name + " get down.");
}
public void OnMouseUp()
{
spring.enabled = false;
rgb2d.isKinematic = false;
clickedOn = false;
Debug.Log (this.gameObject.name + " get up.");
}
此链接也无效Link
public void OnPointerDown(PointerEventData eventData)
{
spring.enabled = false;
clickedOn = true;
Debug.Log (this.gameObject.name + " Was Clicked.");
}
public void OnPointerUp(PointerEventData eventData)
{
spring.enabled = false;
rgb2d.isKinematic = false;
clickedOn = false;
Debug.Log (this.gameObject.name + " Was Clicked.");
}