if (Input.GetMouseButton(0)) { // Ensure the pointer is not over a UI element if…
Jump to turn (6)
- User
if (Input.GetMouseButton(0)) { // Ensure the pointer is not over a UI element if (!EventSystem.current.IsPointerOverGameObject()) { //HandleGroundClick();
codeRay ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; // Perform the raycast if (Physics.Raycast(ray, out hit)) { GameObject hitObject = hit.collider.gameObject; // Check if the GameObject is active and visible if (IsObjectVisible(hitObject)) { Debug.Log("Hit visible GameObject: " + hitObject.name); } else { // Treat as if no visible GameObject was hit HandleGroundClick(); } } else { // No objects were hit, treat as ground click HandleGroundClick(); } } } 希望修改代码,当Hit visible GameObject为 只有BattleFieldSlot(Clone) 时,也要能播放声音