virtual protected void Update() { if (clickToRing && Input.GetMouseButtonDown(0)) { Ray mousePickRay = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(mousePickRay, out RaycastHit hit)) { BellSynthesizer bell = hit.collider.gameObject.GetComponentInChildren <BellSynthesizer>(); if (bell == bellSynthesizer && bell != null) { Ring(hit.point, clickForce); } } } }
void Update() { if (Input.GetMouseButtonDown(0)) { Ray mousePickRay = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(mousePickRay, out RaycastHit hit)) { BellSynthesizer bell = hit.collider.gameObject.GetComponent <BellSynthesizer>(); if (bell == null) { bell = hit.collider.transform.gameObject.GetComponentInParent <BellSynthesizer>(); } if (bell != null) { bell.Play(); } } } }