OnMouseOver don't work

The Function don’t work on my RawImage Object

void OnMouseOver()
	{
		Debug.LogError(gameObject.name);
	}

I tried everything I saw on the forum but I don’t know why nothing work :s
Here my object:
81126-ss2016-10-28at082807.png

I tried with that component :

81127-ss1.png

and with the 2d components too but I can’t find why nothing work…

Thanks.

Yes, Thank You. What I actually want to do is, rotate an object on the local axes. as you mentioned, I used " transform.Rotate(0,180,0);" I also want to move it forward. But for that I cant use local axes, because the axes are constantly rotating and the object won't neatly move forward on the same local axes. Hence I want to know how to move them on the global axes. Do you know, how to move on global axes? Thanks in advance.

2 Answers

2

Try to make your script implementing the IPointerEnterHandler interface :

public class MyClass : MonoBehaviour, IPointerEnterHandler
{
      private void OnPointerEnter(EventSystems.PointerEventData eventData)
      {
             Debug.LogError(gameObject.name);
      }
}

It was more like that : public class Dragdropinventory : MonoBehaviour, IPointerEnterHandler { #region IPointerEnterHandler implementation public void OnPointerEnter (PointerEventData eventData) { Debug.LogError(gameObject.name); } #endregion } but this is working ! thanks :D

Thank You!!! It worked.

If you read the manual, (here) the OnMouseOver also has a special setting for GUI elements, which you are using. Since the Canvas is in the UI layer, I reccomend you don’t try to use colliders :slight_smile:

Thanks for the reply. I changed the layer to UI and I removed my colliders but it still doesn't work :s ... I'm passing a hard time to detect a raw image under my mouse ^^''

Use the method in the answer, Trasform.Translate with the the parameter Space.World. Space.Self = local axes ; Space.World = global axes this parameter is also available for the rotate function: [Transform.Rotate][1] [1]: https://docs.unity3d.com/ScriptReference/Transform.Rotate.html