Okay i have a
thing here and i want when i drag my mouse over the left red panel for my camera to turn. I have the rotation script and everythings good…BESIDE THAT THE MOUSE ENTER WONT WORK HOW DO U WORK IT PLZ HELPHello!
What you need to do is use OnPointerEnter
Here is an example of a script you should attatch to the red box(it “should” work with just images, but if it does not you may need to give the red box a button component).
You need to make sure you have an event system in your scene(it gets added automatically when you add a canvas).
using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
public class PointerEventsController : MonoBehaviour,IPointerEnterHandler, IPointerExitHandler {
public void OnPointerEnter(PointerEventData eventData)
{
Debug.Log("mouse inside"); //start rotation here
}
public void OnPointerExit(PointerEventData eventData)
{
Debug.Log("mouse outside"); // stop rotation here
}
}
You can do a lot of neat things with pointerevent data, and there is also OnPointerDown, which also needs to be inherited, to be used!
Good luck!
