Mac vscode unity mono无法正常加载,c#代码不能正常补全的解决方法

初学unity,用Mac vscode来开发,遇见了不能正常补全代码的问题。能补全代码但是补全的不是unity的代码。

终于解决了。


首先最新版的net.sdk 和 Mono (Stable channel)一定安装好
https://www.mono-project.com/download/stable/
https://learn.microsoft.com/ja-jp/dotnet/core/install/macos
vscode里边该有的扩展插件都按好,这里就不详细说了。

注意,不要把vscode软件放在下载文件夹里-》否则没法把vscode更新到最新版本。最好更新到最新版。

不能正常补全代码主要是是因为mono无法正常加载
下边是解决方法。

In the VS Code menu, go into File / Preferences / Settings.

In the “Search settings” window, type omnisharp.path

Click on “Edit in settings.json” link.

Add (or edit) like this:
“omnisharp.path”: “latest”
“omnisharp.useGlobalMono”: “always”,
“omnisharp.monoPath”: “/Library/Frameworks/Mono.framework/Versions/Current”

然后重启软件

以下是出处和原文:

https://qiita.com/kabosu3d/items/a4bc9abe991f95670964
https://stackoverflow.com/questions/55535177/omnisharp-msbuild-projectmanager-attempted-to-update-project-that-is-not-loaded

Solved (cross checked on Ubuntu 16.04 and CentOS 7):

In the VS Code menu, go into File / Preferences / Settings.

In the “Search settings” window, type omnisharp.path

Click on “Edit in settings.json” link.

Add (or edit) like this: “omnisharp.path”: “latest”

(from: https://github.com/OmniSharp/omnisharp-vscode/issues/2965)

Unityのツールバーから[Unity] - [Preferences] - [External Tools] を選択。[External Script Editor]でVisual Studio Codeを選択しておく。
そして、以下の設定をsettings.jsonに書き込むとコード補完・エラー表示が効くようになる。
“omnisharp.useGlobalMono”: “always”,
“omnisharp.monoPath”: “/Library/Frameworks/Mono.framework/Versions/Current”
うまく機能しない場合は
VSCodeの再起動
OmniSharpのReStart(コマンドパレットで「omni」と入れると候補に出てくる)
をしてみるとよい。
参考:
vs code Problems with C# extension, Some projects have trouble loading due to OmniSharp
https://stackoverflow.com/a/70640179
【vscode/Unity】monoを認識せず、インテリセンスが消えたときの対処法
https://zenn.dev/leaf/articles/ee0b7b796b9036

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值