简体   繁体   English

命名空间“UnityEngine.Experimental”中不存在类型或命名空间名称“Input”

[英]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.

相关问题 Unity 中的命名空间“UnityEngine”中不存在类型或命名空间名称“Windows” - The type or namespace name `Windows' does not exist in the namespace `UnityEngine' in Unity "命名空间“UnityEngine”中不存在类型或命名空间名称“UI”" - The type or namespace name 'UI' does not exist in the namespace 'UnityEngine' 命名空间“UnityEditor.Experimental”中不存在类型或命名空间名称“SceneManagement” - The type or namespace name `SceneManagement' does not exist in the namespace `UnityEditor.Experimental' 命名空间“UnityEngine.Rendering”中不存在类型或命名空间名称“PostProcessing” 统一 package - The type or namespace name 'PostProcessing' does not exist in the namespace 'UnityEngine.Rendering' On unity package Unity 项目构建成功,但 VS Code 抛出命名空间“UnityEngine”中不存在类型或命名空间名称“EventSystems” - Unity project builds successfully, but VS Code throws The type or namespace name 'EventSystems' does not exist in the namespace 'UnityEngine' 命名空间中不存在类型或命名空间名称“Exchange” - The type or namespace name 'Exchange' does not exist in the namespace 类型或名称空间名称“ Confidence”在名称空间中不存在 - The type or namespace name 'Confidence' does not exist in the namespace 命名空间中不存在类型或命名空间名称 - type or namespace name does not exist in the namespace 命名空间中不存在类型或命名空间名称“优化” - The type or namespace name 'Optimization' does not exist in the namespace 类型或名称空间名称在名称空间中不存在 - The type or namespace name does not exist in the namespace
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM