【问题标题】:Unity/C# - Compiler Errors ONLY in VSCode, not Unity Editor or Visual StudioUnity/C# - 仅在 VSCode 中的编译器错误,而不是 Unity 编辑器或 Visual Studio
【发布时间】:2021-10-03 02:01:59
【问题描述】:

当尝试从 Unity 包(特别是 InputSystem)引用一个类时,VSCode 会给我错误 The type or namespace name 'InputSystem' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?) [Assembly-CSharp],即使 Unity 构建和运行都很好,没有任何抱怨,并为 Visual Studio 生成项目文件正常工作。

这开始于我尝试从 Visual Studio 迁移到 VSCode 作为我的主编辑器,因此该过程中的某些东西可能会破坏它们。我尝试了很多不同的方法 - 删除和重新生成 .csproj.sln 文件,卸载、重新安装和更新软件包,甚至删除整个 repo 并重新克隆,但没有解决问题。

【问题讨论】:

    标签: c# visual-studio unity3d visual-studio-code compiler-errors


    【解决方案1】:

    这绝对是一个统一/IDE 集成问题。尝试按照 this 官方指南设置 VSC Unity 支持。

    【讨论】:

      【解决方案2】:

      您是否按照this tutorial 的说明将vs 代码与unity 结合使用?因为需要安装一些东西才能统一使用vs代码。

      【讨论】:

        【解决方案3】:

        由于我没有足够的信誉,所以我写这个作为答案。

        您是如何从 Visual Studio 迁移到 VS Code 的?我希望您在编辑 > 首选项 > 外部工具> 外部脚本编辑器中更改它。

        【讨论】:

          猜你喜欢
          • 2019-11-16
          • 1970-01-01
          • 2010-10-09
          • 2014-01-29
          • 2020-08-24
          • 2011-01-06
          • 2010-12-18
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多