How to avoid OnMouseOver?

Hi there! I’m making a game on Android. I’ve heard that I should avoid OnMouseOver on mobile devices… so, how to avoid this function? I need to check if user clicks on some object. The way I’m doing this:

void OnMouseOver()
	{
		if (Input.GetMouseButton(0))
		{
			// bla bla bla	
		}
	}

Help me with this, plz! Thank you!

You can actually do all your input code without using Unity’s input callbacks, in an Update loop. Particularly on mobile devices, though Unity may provide some mechanism that interprets touches as mouse buttons, you will probably want to do your input processing in your Update function. You can do something like this:

private void Update()
{
    for(int i = 0; i < Input.touchCount; i++)
    {
        Touch touch = Input.GetTouch(i);
        if(touch.phase == TouchPhase.Began)
        {
            //TODO: Process touch began.
        }
        //TODO: Use additional touch phases for other logic.
    }
}

You can also adjust for your particular case; for example, if you’re logic only ever requires the use of one touch, you can probably avoid iterating over all touches and just check Input.touchCount > 0 and use Input.GetTouch(0).

You may want to just review Unity’s touch input API: Unity - Scripting API: Input. Touch input code doesn’t have to be complicated, but it actually can get quite complicated when you start needing to handle multitouch logic or identify gestures like swipes or taps.