Files
ScienceLab.Density/Assets/Scripts/Lesson_2/ScrollLeverOnHover.cs
2026-06-04 00:55:54 +03:00

22 lines
592 B
C#

using UnityEngine;
public class ScrollLeverOnHover : MonoBehaviour
{
void Update()
{
float scroll = Input.mouseScrollDelta.y;
if (scroll == 0) return;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out RaycastHit hit))
{
if (hit.collider.gameObject.tag == "LeverParent")
{
StrikerLeverController slc = hit.collider.gameObject.GetComponent<StrikerLeverController>();
if (slc != null) slc.currentAngle += scroll;
}
}
}
}