VSCode配置(Unity)

一、下载VSCode

https://code.visualstudio.com/

二、VSCode C#配置:

安装 .net core SDK

下载 .NET(Linux、macOS 和 Windows)

这里要注意一点(虽然好像6.0的版本也什么没问题):

4.7.1是符合的版本

VSCode配置(Unity)_第1张图片

 安装:

VSCode配置(Unity)_第2张图片

 VSCode配置(Unity)_第3张图片

三、安装C#插件

  • C#

  • Auto-Using for C#

四、创建工程(调试)

  • 从 C:\Program Files\dotnet 路径打开终端 cmd

  • dotnet new console -o 项目路径 (eg:dotnet new console -o D:\cs_project)

  • code .

  • 弹出VSCode界面

  • 在VSCode终端 ,输入 dotnet run

这里会遇到一个问题

新增启动项目文件报错:Could not execute because the application was not found or a compatible .NET SDK is not installed.

完整错误如下:

Could not execute because the application was not found or a compatible .NET SDK is not installed.`
`Possible reasons for this include:`
`* You intended to execute a .NET program:`
`The application 'new' does not exist.`
`* You intended to execute a .NET SDK command:`
`It was not possible to find any installed .NET SDKs.`
`Install a .NET SDK from:`
`https://aka.ms/dotnet-download
  • 问题原因:program file和program file(x86)dotnet命令冲突了

  • 解决办法:将 C:/program file(x86)/dotnet/下的dotnet.exe 删除即可

五、VSCode的Unity配置

Visual Studio Code and Unity

VSCode配置(Unity)_第4张图片

六、安装mono

(.net 前面步骤已经完成了)

Download - Stable | Mono

七、在unity中将VSCode设置为默认编辑器:

Edit -> Preferences -> External Tools

External Script Editor选项 , 选VSCode

八、安装插件:

  1. Debugger for Unity (会自动安装C#)

  2. Chinese(Simplified)(简体中文)

  3. Unity Code Snippets

  4. Unity Code Snippets Improved

  5. Unity Tools

  6. Prettier-Code formatter

九、安装运行插件和配置:

  1. Code Runner -> 运行插件

  2. 在设置窗口,搜索run in terminal ,找到Run In Terminal勾选

  3. VSCode配置(Unity)_第5张图片

    VSCode配置(Unity)_第6张图片

  4.  cd $dir && dotnet run $fileName

你可能感兴趣的:(vscode,编辑器,unity,c#)