赞
踩
初学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
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。