There is a script that creates a ray when clicking on the mouse.
ray = camera.ScreenPointToRay (Input.mousePosition); There is also a Canvas on stage, and a Button in it. When the button is pressed, a beam is also created, which I do not need. How not to create a beam, only when you press the button?
if (Hit.collider.gameObject.CompareTag("button")) return;that is, if a button is caught, then do nothing - Alexey ShimanskyPhysics.Raycastand not justif- Alexey ShimanskyRaycastHit hit; Ray ray = camera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { if (hit.gameObject.CompareTag("button")) { return; } //здесь действия не связанные с кнопкой }RaycastHit hit; Ray ray = camera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { if (hit.gameObject.CompareTag("button")) { return; } //здесь действия не связанные с кнопкой }RaycastHit hit; Ray ray = camera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { if (hit.gameObject.CompareTag("button")) { return; } //здесь действия не связанные с кнопкой }inspired by docs.unity3d.com/ru/current/Manual/CameraRays.html - Alexey Shimansky