#on mouse drag doesnt work
1 messages · Page 1 of 1 (latest)
private void OnMouseDrag()
{
Debug.Log("Gets dragged");
}
i have a special problem with this function
it is somehow only working after i slighly move the object in the inspector
after that the function works just fine
also if this helps its in 2d space
talking about this?
so you've got an object that you're clicking on in game, right?
i am
the even more wierd thing is that on some objects it works and on some it doesnt
wait
i will record it
yes this one
So some objects don't work, but then you move them on any axis and now they work?
yes
If you're moving them on the z axis I could see how maybe that could affect it, but only if something else was covering it up and now it's not
nope z axis is the same
already checked that
What if you slightly move a box and then switch to selecting a different game object?
Then drag the box
I dont really understand
So I should move the box via code and then?
I will problaly just do a custom solution since its kinda buggy and I dont have the whole day to fix it
private void Update()
{
if (Input.GetMouseButton(0))
{
RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
if(hit.collider == null) return;
if(hit.transform == transform) Debug.Log("Is Dragging"); //<--- Code here
}
}
This is what I come up with