【发布时间】:2021-03-09 08:32:19
【问题描述】:
我目前正在尝试检测我目前在 Unity 引擎中进行的 2D 游戏的鼠标滚轮滚动输入。
我正在使用新的输入系统,但我目前被以下代码卡住了。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem.Controls;
public class ZoomController : MonoBehaviour
{
private PlayerControls playerControls;
private void Awake()
{
playerControls = new PlayerControls();
}
private void OnEnable()
{
playerControls.Enable();
}
private void OnDisable()
{
playerControls.Disable();
}
void Start()
{
}
void Update()
{
if (playerControls.Land.Zoom.ReadValue<Vector2>().y >= 1)
{
Debug.Log("Scroll 1");
} else if (playerControls.Land.Zoom.ReadValue<Vector2>().y <= -1)
{
Debug.Log("Scroll 2");
}
}
}
如果我运行代码没有任何反应,我不知道为什么。
【问题讨论】:
标签: c# unity3d input user-input mousewheel