OnTriggerEnter2D, OnTriggerStay2D work but not OnTriggerLeave2D

Hi Folks,

I use mouse to change an Object A’s position on the screen with OnDragStart, OnDrag, OnDragEnd functions and want to know whether it is intersected with Object B. Here is my code…

   void OnTriggerEnter2D(Collider2D other){
	Debug.Log("trigger enter  ");
}

void OnTriggerStay2D(Collider2D other){
	Debug.Log("trigger stay   ");
}

void OnTriggerExit2D(Collider2D other){
	Debug.Log("trigger exit  ");
}

but the weird thing is only OnTriggerEnter2D and OnTriggerStay2D are called, not InTriggerExit2D. It seems others also have the same issue but i couldn’t find a clear answer. Anyone here can help? Thx in advance.

I am really unsure why this is happening. Perhaps you could change it so it does not use a trigger by using OnCollisionEnter(Collider2d collision). And if the collision.collider.name == “Object B” then Debug.Log("Trigger enter ");