unity select object with mouse
void Update() { if (Input.GetMouseButtonDown(0)) { RaycastHit hitInfo = new RaycastHit(); bool hit = Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo); if (hit) { // any object hit Debug.Log("Hit " + hitInfo.transform.gameObject.name); // filter with tag name if (hitInfo.transform.gameObject.tag == "TagName") { // do something.. } } } }