Unity_1lab/1 laba/Assets/Keypad/Scripts/KeypadInteractionFPV.cs
2025-09-15 19:16:35 +03:00

26 lines
634 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace NavKeypad {
public class KeypadInteractionFPV : MonoBehaviour
{
private Camera cam;
private void Awake() => cam = Camera.main;
private void Update()
{
var ray = cam.ScreenPointToRay(Input.mousePosition);
if (Input.GetMouseButtonDown(0))
{
if (Physics.Raycast(ray, out var hit))
{
if (hit.collider.TryGetComponent(out KeypadButton keypadButton))
{
keypadButton.PressButton();
}
}
}
}
}
}