I am currently developing a game that uses the OnMouseOver() function of a MonoBehaviour object.
Is there a true alternative for iPhone? Would I be better of coding my own?
Thanks in advance
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.
Sign up to join this communityI am currently developing a game that uses the OnMouseOver() function of a MonoBehaviour object.
Is there a true alternative for iPhone? Would I be better of coding my own?
Thanks in advance
You can use the new TouchInputModule on iOS and other mobile devices.
You just need a collider on the object you want to touch or hover, EventSystem AND TouchInputModule in the scene, and then it basically works this way:
public class TouchInputExample : MonoBehaviour, IPointerDownHandler, IPointerEnterHandler, IPointerExitHandler
{
public void OnPointerDown(EventSystems.PointerEventData eventData)
{
Debug.log("Touched");
}
public void OnPointerEnter(EventSystems.PointerEventData eventData)
{
Debug.log("Hover start");
}
public void OnPointerExit(EventSystems.PointerEventData eventData)
{
Debug.log("Hover stop");
}
}
As mentioned, you can not get a hover status on a touch screen. It always either touches or not.