0
\$\begingroup\$

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

\$\endgroup\$
1
  • \$\begingroup\$ There is no support in unity for your finger hovering over the screen... You will have to implement a touch system yourself. Input.touches is an array of current fingers on the screen. You might find that useful. \$\endgroup\$
    – Savlon
    Jul 31, 2015 at 9:23

1 Answer 1

1
\$\begingroup\$

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.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .