[英]The type or namespace name 'Input' does not exist in the namespace 'UnityEngine.Experimental'
I am using unity's new input system and getting this error, I tried a lot to fix it but can't find the problem.我正在使用统一的新输入系统并收到此错误,我尝试了很多来修复它但找不到问题。 Please help me.
请帮我。
Error:错误:
Assets\Player01.cs(4,32): error CS0234: The type or namespace name 'Input' does not exist in the namespace 'UnityEngine.Experimental' (are you missing an assembly reference?)
Full Script(C#):完整脚本(C#):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Experimental.Input;
public class Player01 : MonoBehaviour
{
public InputMaster controls;
void Awake ()
{
controls.Player01.Shoot.performed += _ => Shoot();
}
void Shoot ()
{
Debug.Log("We shot the sherif!");
}
private void OnEnable()
{
controls.Enable();
}
private void OnDisable()
{
controls.Disable();
}
}
The problem is that there is no namespace of UnityEngine.Experimental.Input
.问题是
UnityEngine.Experimental.Input
没有命名空间。 But, it only says “'Input' does not exist in the namespace 'UnityEngine.Experimental'”.但是,它只说“‘输入’在命名空间‘UnityEngine.Experimental’中不存在”。 'Experimental' does exist and 'Input' does not.
“实验”确实存在,“输入”不存在。 However, 'InputSystem' does.
但是,“输入系统”可以。 And that is the one you are looking for, not 'Input'.
那就是您要寻找的那个,而不是“输入”。 You should change the first line to this:
您应该将第一行更改为:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Experimental.InputSystem;
public class Player01 : MonoBehaviour
...
Just in case, if the first solution did not work, Close vs studio / code if open, then go to Edit -> Project Settings -> Input System Manager.以防万一,如果第一个解决方案不起作用,关闭 vs studio / code 如果打开,然后 go 编辑 -> 项目设置 -> 输入系统管理器。 There will be only one option available.
将只有一个选项可用。 Click the button, save your scene.
单击按钮,保存您的场景。 Open a script.
打开一个脚本。 This worked for me.
这对我有用。 A lot of tutorials do not mention this part.
很多教程都没有提到这部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.