private void Update() { if (Input.GetMouseButtonDown(0)) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, range)) { if (hit.transform != null) { PrintName(hit.transform.gameObject); //if (hit.transform.gameObject) == Button } DoorController targetButton = hit.transform.GetComponent <DoorController>(); if (targetButton != null) { targetButton.ButtonClick(); } } } }