我是Unity的完整初学者,以及Visual Studio 2022。
我试图制作2D游戏,并且一直在遵循本教程, https://www.youtube.com/watch?v=7iywpzl9gkm 。在25:11,我们向我们展示了如何制作脚本来控制玩家运动。当我要使用Visual Studio代码时,defececode的Unity调试器被弃用,不再功能。
为了解决这个问题,我切换到Visual Studio2022。我安装了“以Unity”和“ .NET桌面开发”模块安装了“游戏开发”模块,并将默认外部编辑器设置为“ Unitity” nounity to Visual Studio 2022。我被另一种形式指示。
尽管如此,我遇到错误CS0246:找不到类型或名称名称'inputValue'
(视频中的27:29,我使用Unity的“ player Input”模块)
库也没有点亮绿色,但是我不确定这只是我们之间的主题差异,但这是一个具有默认的黑暗模式的干净安装。
I am a complete beginner to Unity, as well as Visual Studio 2022.
I was trying to make a 2D game, and have been following along this tutorial, https://www.youtube.com/watch?v=7iYWpzL9GkM. At 25:11, we are shown how to make a script to control the player movement. While I was going to use Visual Studio Code, the Unity debugger for VScode is deprecated, and no longer functions.
To solve this I switched to Visual Studio 2022. I installed the 'Game Development with Unity' and the '.NET desktop development' modules, and set the default external editor within Unity to Visual Studio 2022. I also regenerated the .csproj files as I was instructed in another form.
Despite this, I encounter error CS0246: The type or namespace name 'InputValue' could not be found
(27:29 in the video, I am using the 'Player Input' module from Unity)

The libraries also do not light up green, but I am not sure if that is just a theme difference between us, but this is a clean install with the default dark mode.
发布评论
评论(1)
在视频中22:20 他们从视频中获取输入系统包软件包管理器。
是编译器,告诉您找不到定义InputValue的命名空间。
要解决此问题,您需要在文件顶部添加“使用”语句,以告诉编译器在哪里可以找到该功能。
他们的代码也无法没有它,实际上您看到他们意识到了错误并也更正了错误。
At 22:20 in the video they get the Input System package from the Package Manager.
The documentation for InputValue says it's from the UnityEngine.InputSystem namespace, so when you see the error:
It's the compiler telling you it can't find the namespace where InputValue is defined.
To solve this problem, you need to add a "using" statement at the top of the file to tell the compiler where to find that function.
Their code won't work without it, either and actually at 31:50 in the same video you see them realize the error and correct it as well.