折腾了两天,终于解决了VSCode开发Unity不会代码自动补全的问题,本来就不熟悉Unity相关的api,如果不能自动补全简直就是劝退。中途有尝试Visual Studio,然并卵,翻了一堆的网页,终于总结出了最简单的配置过程。
配置后的效果如下:
1.安装Unity
2.下载安装.Net Core SDK
https://dotnet.microsoft.com/download/dotnet-core/3.1
`➜ ~ dotnet --version``3.1.402`
3.下载安装Mono SDK
https://www.mono-project.com/download/stable/
`➜ ~ mono --version``Mono JIT compiler version 6.12.0.93 (2020-02/620cf538206 Tue Aug 25 14:04:52 EDT 2020)``Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com` `TLS:` `SIGSEGV: altstack` `Notification: kqueue` `Architecture: amd64` `Disabled: none` `Misc: softdebug` `Interpreter: yes` `LLVM: yes(610)` `Suspend: hybrid` `GC: sgen (concurrent by default)`
4.安装VSCode
4.1 安装VSCode插件
`C#``C# Extensions``C# FixFormat Fixed``Debugger for Unity``Unity Tools``Unity Code Snippets``Unity Snippets`
4.2 VSCode配置omnisharp路径
如果不配置这个,确实可以开发了,但是各种类型不认,一片红设置路径:
Code -> Preferences -> Settings, 检索mono, 点击settings.json
配置omnisharp(很重要)
"omnisharp.monoPath": "/Library/Frameworks/Mono.framework/Versions/Current/Commands/mono",``"omnisharp.useGlobalMono": "always"`
设置.zshrc/.bash_profile环境变量(很重要)
export FrameworkPathOverride=/Library/Frameworks/Mono.framework/Versions/Current`
5.设置Unity代码编辑器
现在就可以各种愉快的开发Unity了~