折騰了兩天,終于解決了VSCode開發(fā)Unity不會代碼自動補(bǔ)全的問題,本來就不熟悉Unity相關(guān)的api,如果不能自動補(bǔ)全簡直就是勸退。中途有嘗試Visual Studio,然并卵,翻了一堆的網(wǎng)頁,終于總結(jié)出了最簡單的配置過程。
配置后的效果如下:
image
1.安裝Unity
2.下載安裝.Net Core SDK
image
https://dotnet.microsoft.com/download/dotnet-core/3.1
`? ~ dotnet --version``3.1.402`
3.下載安裝Mono SDK
image
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路徑
如果不配置這個,確實可以開發(fā)了,但是各種類型不認(rèn),一片紅image
設(shè)置路徑:
Code -> Preferences -> Settings, 檢索mono, 點擊settings.json
image
image
配置omnisharp(很重要)
"omnisharp.monoPath": "/Library/Frameworks/Mono.framework/Versions/Current/Commands/mono",``"omnisharp.useGlobalMono": "always"`
設(shè)置.zshrc/.bash_profile環(huán)境變量(很重要)
export FrameworkPathOverride=/Library/Frameworks/Mono.framework/Versions/Current`
5.設(shè)置Unity代碼編輯器
image
現(xiàn)在就可以各種愉快的開發(fā)Unity了~