2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

UnityでビルドエラーになっているのにVisual Studioでは赤線の表示がないとき(「その他のファイル」の直し方)

Last updated at Posted at 2021-05-13

はじめに

スクリプトにビルドエラーが有る場合  
UnityのConsoleや左下のステータスでエラーが有ることが表示されます。

image.png

これらの項目をダブルクリックすることにより、Visual Studioが開き該当の箇所を直したいわけなんですが、

なぜか、赤線が表示されないことがあります。

image.png

左上が「その他のファイル」になってないかを確認する

実は、ここが「その他のファイル」になっていると、スクリプトがビルドエラーだとしても
赤線で表示されません。

image.png

直し方

Unityの「Edit」→「Preferences...」を開きます。

image.png

「Preference」画面の「External Tools」の「External Script Editor」を
「Visual Studio 〇〇」にするようにしてください。

それっぽいものが複数出てる場合はどれを選んでも大丈夫だと思います。

image.png

これを設定後、Visual Studioを閉じて
UnityからVisual Studioを開き直したら、ちゃんと赤線が表示されるようになると思います。

image.png

要因

C#のファイルを、Unityソリューションとして開いていないのが原因であり、
うまく行かなかったときは、ただ単にC#ファイルを開くモードになっていた。

どういうときにこうなるのか (原因は不明)

原因は不明です。今まで何もなかったのに、突然なったという声も聞いたり
Colabと連携しているときになったりとか、Unityのバグとかに起因するかもしれません。

なにか分かる人がいればコメントください。

2
0
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
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?