Here I have a little code and I am trying to drag object with OnMouseDown()
function.I try bellow code but is not working. I have 2D object with 2Dcircle collider
. This 2D circle collider can't detect OnMouseDown()
. I want to detect mouse click, if object clicked not on other screen/ camera screen.
Here is my little code.
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.");
}
This link also not working 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.");
}