windows - Input.GetAxis("Mouse X") 不适用于某些 Windows 配置
问题描述
public float GetAxis()
{
if (inputDevice == InputDevice.MouseKeyboard)
{
return Input.GetAxis(this.buttonName);
}
}
此代码在我的 Windows 7 x64 PC 上运行良好。我的项目输入设置是序数:
输入设置:
但我在 youtube 上观看了一些人们玩我的游戏的视频。他们不能在里面使用鼠标。看起来Input.GetAxis("Mouse X")
并Input.GetAxis("Mouse Y")
没有为它们返回正确的值,并且它们无法控制游戏中的相机。
其他输入对他们来说效果很好。我的 Unity 版本是5.6.0f3
,我无法升级到实际版本,因为游戏的代码太复杂了。
如何进行故障排除和修复?我还没有为其他平台构建,然后是 windows x86 和 x64。
输入对象被构造:
public GenericInput rotateCameraXInput = new GenericInput("Mouse X", "RightAnalogHorizontal");
要读取增量鼠标移动,我在 LateUpdate() 中运行此方法:
protected virtual void CameraInput()
{
if (tpCamera == null || cc.lockCamera)
return;
var Y = rotateCameraYInput.GetAxis();
var X = rotateCameraXInput.GetAxis();
}
解决方案
I've come across this issue myself while using an RDP session or some kind of remote viewer such as TeamViewer. Mouse X and Mouse Y read the output directly from a device. If the device is not directly plugged into the machine that the player is being ran on then the inputs will not be properly retrieved. I'm not sure if this is the case for you, but this is the only instance I can think of these not being picked up.
Maybe you should add a bit of code that gets the mouse position each frame and outputs the difference, this would bypass the Mouse X/Y inputs anyways.
推荐阅读
- python - Python创建自定义直方图
- python - 当我在 plotly 中绘制气泡图时出现错误
- android-studio - 运行 Android Studio 应用程序时出现 Dex 文件错误
- r - 重复列在另一列中的唯一值的次数
- android - 无法为 SoftwareComponentInternal 获取未知属性“发布”-Maven 发布插件项目 gradle
- python-3.x - 如何使用 iso-8859-1 对 pandas 进行编码?
- keil - 如何解决错误 - L6236E:没有部分匹配选择器 - 没有部分是 FIRST/LAST
- ios - 是否可以在对象数组中使用 UIImage?
- c# - SshKeyGenerator 生成的公钥/私钥不起作用
- asp.net-core - 在 Windows 中使用 CLI 在 .Net 5.0 中创建 WebAPI 时出错