I just tried this code instead of the mouse input version, and it works perfectly:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AndroidTest : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
void Update()
{
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended)
{
Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
if (Physics.Raycast(ray, out RaycastHit hit, Mathf.Infinity))
{
Debug.DrawRay(ray.origin, ray.direction * 10, Color.green, 5f);
Debug.Log("AndroidTest hit:" + hit.collider.name);
}
}
}
}