14

I just started learning unity and I created a project. But my project doesn't have a sln file included in. Every time I create a C# script and open it in Xamarin Studio I can't have any intellisense.

  1. Is it normal not to have sln file in unity project?
  2. If not, how can I add solution file to project?
  3. Why that happened?
Rune Vejen Petersen
  • 3,201
  • 2
  • 30
  • 46
aakpro
  • 1,538
  • 2
  • 19
  • 53

7 Answers7

30

If "Open C# Project" doesnt create the .sln file, try updating your external tools first.

In Unity, go to Edit > Preferences, and make sure that Visual Studio is selected as your preferred external editor.

This created the sln file for me.

SSchmid
  • 431
  • 4
  • 3
  • 2
    If it is already selected to Visual Studio and you're still experiencing this problem, try clicking "Browse", then select Notepad (or some other application), then set it back to Visual Studio and that should solve the issue. – sab669 May 01 '20 at 23:44
  • Switching External Script Editor = Visual Studio Code created the sln for me – HappyGoLucky Jan 30 '21 at 02:43
  • This was the solution to my problem, (I was unable to pull up solution, and if I opened a C# file, the UnityEngine namespace wasn't recognized. Thanks. – CPearson Dec 09 '21 at 01:01
6

I finally found the answer.

I closed Xamarin and inside Unity went Assets > Sync MonoDevelop Project Doing this created the two .sln projects: -csharp.sln and .sln

aakpro
  • 1,538
  • 2
  • 19
  • 53
  • 4
    On Unity 5 OS X it is `Assets -> Open C# Project` – Jimbali Jan 15 '16 at 13:58
  • Open C# Project should be it's own answer. There's a problem with my installed version of Visual Studio, so Unity is failing this step. Open C# Project generated the sln for me, I just open it manually. – thehelix Oct 07 '19 at 15:12
6

For people looking for answers on newer versions of Unity you may have to build your C# project.

To do this go into File > Build Settings then select the option Create Visual Studio Solution. Then build that and your file explorer will ask you for which folder you want your visual studio solution to be placed into. Then Visual Studio should behave correctly.

  • Just to be clear: This option does not exist in the Android and WebGL Build Setting Platforms. Does seleting the option for the Windows &c Platform also solve this problem? – MXMLLN Jan 06 '23 at 09:25
  • So this seems to generate a different .sln to the one that is made via "Edit->Preferences->External Tools->Regenerate project files". The latter solved it for me. (Does anyone know why these are different and when each should be used?) – RJFalconer Jun 26 '23 at 02:58
2

For people looking for answers on newer versions of Unity you may have to build your C# project.

First install windows build also in unity hub then select target platform to windows. and now you can see visual studio solution checkbox.

To do this go into File > Build Settings then select the option Create Visual Studio Solution. Then build that and your file explorer will ask you for which folder you want your visual studio solution to be placed into. Then Visual Studio should behave correctly.

1

Like the post by SSchmid suggests, go into preferences and have Visual Studio as your preferred editor.

I was having a sync issue and the Solution wasn't showing the name of the unity project, ultimately interrupting intellisence.

Found in my settings that the code editor was set to General and not Visual Studio specifically.

Setting it to VS solved it for me.

Orillix
  • 11
  • 2
1

Create Visual Studio Solution Option

A screenshot to help those who are too lazy to read.

Tigertron
  • 628
  • 6
  • 6
1

VS Code

  1. Ensure the Visual Studio Code Editor package is installed in the Package Manager.

  2. Once this is added, the vs code option will be available in Preferences -> External Tools.

enter image description here

Note: This is not the same as selecting the vs code executable manually via Browse..., that method does not generate .sln files.

chantey
  • 4,252
  • 1
  • 35
  • 40