はじめに
ずっと「Visual Studio for Mac」を使っていたのですが、2024年8月にサポートが終了してしまうとのことなので少し早いですが「Visual Studio Code」に作業環境を移行した話です。少しつまづいたので残しておきます。
Microsoft は、Visual Studio for Mac の提供終了を発表しました。 Visual Studio for Mac は、2024 年 8 月 31 日でサポートが終了します。 代替手段は次のとおりです。
・C# 開発キットおよび関連する拡張機能 (.NET MAUI、Unity など) を含む Visual Studio Code。
・Mac 上の VM の Windows 上で実行されている Visual Studio。
・クラウド内の VM の Windows 上で実行されている Visual Studio。
![](https://learn.microsoft.com/dotnet/media/dotnet-logo.png)
久しぶりに「External Script Editor」を変更
挙動の軽さに惹かれて2年くらい前に「Visual Studio Code」をメインに使おうと移行を試みたことがあったのですが、インテリセンスや定義元ジャンプなどが効かなくなったりして不安定だったので諦めたことがあります。
以前と比べて今はどうなのか? 久しぶりにUnityの「External Script Editor」を「Visual Studio Code」へ変更しました。
- Visual Studio Code 1.84.1
- Unity 2022.3.10
- Visual Studio Editor package 2.0.22
![](https://kingmo.jp/kumonos/wp-content/uploads/2023/11/vcode0.jpg)
プラグインのインストールとレガシーパッケージ削除
「Visual Studio Code」起動するとUnity用のプラグインをおすすめされたのでインストール
Unity -Integrates Visual Studio Code with Unity
![](https://kingmo.jp/kumonos/wp-content/uploads/2023/11/vcode2-1024x283.jpg)
「Visual Studio Code Editor package」はレガシー扱いになったようなのでUnityエディター側で削除。 逆に「Visual Studio Editor package」は最新版へ更新。
![](https://kingmo.jp/kumonos/wp-content/uploads/2023/11/vcode1.jpg)
そしてエラー
……定義元ジャンプ「F12」が効かない。参照元検索「Shift+F12」も効かない。これじゃあまともに使えないTT
よく見ると「出力(C#)」に下記のエラーが表示されていました。
Failed to find dotnet info from path, falling back to acquire runtime via ms-dotnettools.vscode-dotnet-runtime
Error running dotnet –info: Error: Command failed: dotnet –info
/bin/sh: dotnet: command not found
Dotnet path: /Users/***/Library/Application Support/Code/User/globalStorage/ms-dotnettools.vscode-dotnet-runtime/.dotnet/7.0.13~x64/dotnet
Activating C# + C# Dev Kit + C# IntelliCode…
先ほど入れたプラグイン「Unity-Integrates Visual Studio Code with Unity」の必要条件にも「.NET7」が記載されていました。
Requirements
・Unity 2019 LTS or greater.
・Activated C# Dev Kit extension in Visual Studio Code.
・.NET 7 SDK or greater, the C# Dev Kit will install it if required.
・Visual Studio Editor Unity package 2.0.20 or greater.
どうやらPCに入っている「dotnet」が古いようなので、最新版「.NET7.0」をインストール。
![](https://dotnet.microsoft.com/blob-assets/images/dotnet-icons/square.png)
ついでに、古い「dotnet」もお掃除。
![](https://learn.microsoft.com/dotnet/media/dotnet-logo.png)
ここまでやって「Visual Studio Code」を起動してみたところ定義元ジャンプができるようになりました!
<追記> ところが……
Unityを再起動したり違うプロジェクトを開いたりすると、上記と同じ「Failed to find dotnet info from path」エラーが発生。
その場合は「Visual Studio Code」を再起動するかPCを再起動すると直ります。(なんか環境パスが不安定^^;)
おわりに
少しつまづきましたが無事「Visual Studio Code」をメインに使う準備ができました。ショートカットは覚え直しですが「Visual Studio for Mac」に比べて挙動が軽いのは良いですね。早く慣れたいと思います。
参考
![](https://qiita-user-contents.imgix.net/https%3A%2F%2Fcdn.qiita.com%2Fassets%2Fpublic%2Farticle-ogp-background-412672c5f0600ab9a64263b751f1bc81.png?ixlib=rb-4.0.0&w=1200&mark64=aHR0cHM6Ly9xaWl0YS11c2VyLWNvbnRlbnRzLmltZ2l4Lm5ldC9-dGV4dD9peGxpYj1yYi00LjAuMCZ3PTk3MiZoPTM3OCZ0eHQ9JUUzJTgwJTkwTWFjJUU1JTkwJTkxJUUzJTgxJTkxJUUzJTgwJTkxVlNDb2RlJUUzJTgxJUE3JUU1JUJGJTg1JUUzJTgxJTlBJUU4JUE2JTlBJUUzJTgxJTg4JUUzJTgxJUE2JUUzJTgxJThBJUUzJTgxJThEJUUzJTgxJTlGJUUzJTgxJTg0JUUzJTgyJUI3JUUzJTgzJUE3JUUzJTgzJUJDJUUzJTgzJTg4JUUzJTgyJUFCJUUzJTgzJTgzJUUzJTgzJTg4JUU5JTlCJTg2JnR4dC1hbGlnbj1sZWZ0JTJDdG9wJnR4dC1jb2xvcj0lMjMyMTIxMjEmdHh0LWZvbnQ9SGlyYWdpbm8lMjBTYW5zJTIwVzYmdHh0LXNpemU9NTYmcz0wMTE4YzU4NTgwZDkwNGZhODcyNmJjZDYwN2M4MGMyYg&mark-x=142&mark-y=57&blend64=aHR0cHM6Ly9xaWl0YS11c2VyLWNvbnRlbnRzLmltZ2l4Lm5ldC9-dGV4dD9peGxpYj1yYi00LjAuMCZoPTc2Jnc9NzcwJnR4dD0lNDAwMWVuJnR4dC1jb2xvcj0lMjMyMTIxMjEmdHh0LWZvbnQ9SGlyYWdpbm8lMjBTYW5zJTIwVzYmdHh0LXNpemU9MzYmdHh0LWFsaWduPWxlZnQlMkN0b3Amcz04OWI0ZmZkZTVlNjIwZGNlMmMxNWYwMzFmMGVkOTNjZA&blend-x=142&blend-y=486&blend-mode=normal&s=eef9b7f0c816352904893368769fe0cc)
![](https://www.orionn.silver-fruit.com/wp-content/uploads/2021/04/SDKエラーアイキャッチ-1.jpg)