LoginSignup
11
12

More than 5 years have passed since last update.

Unity - Visual Studio Codeの環境設定ではまったこと

Posted at

目的

UnityでVisual Studio Codeのコード補完効かせてコーディング出来るようにする
既にこういう記事あふれてるけど、C# Extensionsと競合するとエラー出ないのが分からず多少はまったので次回構築用にメモ

Dependencies

公式

UnityもMonoもバージョンの移り変わりが早いので、下記で詳しいやり方が書いてあるのでそこを参照した方が確実です(英語)
https://code.visualstudio.com/Docs/runtimes/unity

ここの内容を斜め読みしながら自分がやったことのメモ

諸々必要なものをインストール

mono最新

brew install monoでインストールできる

自分の環境の場合

curl: (7) Failed to connect to storage.bos.xamarin.com port 80: Operation timed out
Error: Failed to download resource "mono--monolite"
Download failed: http://storage.bos.xamarin.com/mono-dist-4.0.0-release/c1/c1b37f29b1a439acf7ef42a384550ab1dca5295a/monolite-117-latest.tar.gz

とエラーが出たので下記から最新をインストール
http://www.mono-project.com/download/
本当はOmniSharpのバージョンによって最新でなくても問題ないです

UnityのVisual Studio Codeプラグイン

https://github.com/dotBunny/VSCode.git
をダウンロードしてAssets/Plugins/Editor/に配置

Unity > Preferences からEnable Integrationにチェック
その他はお好みで

Visual Studio Codeを開いて各プラグインをダウンロード

Visual Studio Code上で
Ctrl-Shift-P (Windows, Linux) or Cmd-Shift-P (OSX)
出てきたウィンドウで下記をそれぞれインストール

ext install omnisharp
ext install unity-snippets
ext install unity-tools
ext install unity-debug

はまったとこ

OmniSharpだけ入ってMonoのバージョンが合わないとProject開いた時ログでOmnisharpエラーになる
自分の環境だとC# Extensionsが入っていてそれと競合したらしく、全部入れてからVSCode起動しても補完されずOmnisharpも起動してたので、注意

C# Extensionsは、
ext install csharp
で入れられるやつ(不要)
公式によると、プロジェクト開く際に

Project-csharp.sln
Project.sln

と出てきたやつの-csharpついてる方選ぶとアンインストールしなくてもいける?らしい
出てこなかったので試してません

UnityのプロジェクトをVisual Studio Codeで開く

Unityでプロジェクトを開き、

Open C# Project In Code. 

でVisual Studio Codeを開く
問題なければIと打つとInputとか出てくるので補完を確認

以上

11
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
12