I have this code and want to debug a message when the user move the cursor over an object, but it only works when the object is just at the bottom of the camera. Can this be because my camera is instantiated?
using UnityEngine;
using System.Collections;
public class debugMessage : MonoBehaviour
{
void OnMouseEnter()
{
Debug.Log("Entered");
}
void OnMouseExit()
{
Debug.Log("Exited");
}
}
Can someone tell me why does this happen?
Thank you in advance.
Does the object have multiple colliders? The mouse functions will only be called if the mouse is over the object's own collider.
I suspect you might have overlapping colliders in your object, hence it not being able to detect mouse events from certain angles.
But as Uzquiano said, we need more information on the setup to find out what's going on... or else it's all guesswork for us.
Cheers
I got it. Because I was using the unisky pack, I added a plane that had a mesh collider(lighting) that prevent me from clicking the object if i wasn't to near it.