Import C# project into my Unity solution

I’ve got a C# project (a game-agnostic networking framework called Networking) that I’d like to use with my Unity solution, in MonoDevelop. I’ve got it working when it’s a standalone solution/project (i.e., not integrated within Unity’s solution), and I’d imagine I can also get it working as a compiled DLL by placing it in the Plugins folder of my Unity project. However, I want to edit the C# project alongside my Unity code, in the same editor, and I’m running into issues.

What I have sorta working is this: I let Unity generate its .sln file, then import my project’s existing .csproj file. That lets me have the Assembly-CSharp project alongside my Networking project. It seems to work, until Unity sees any new file and regenerates its .sln file, clobbering mine, and removing any references to my Networking project.

I’ve also tried to import my Networking project’s source under the Plugins folder, which puts my source under the Assembly-CSharp-firstpass project that Unity generates. This might work fine but for the need to have multiple, disparate 3rd party projects co-existing within the same project. It seems less than ideal – if it even works, I haven’t thoroughly tested this – especially when it comes to DLL references said projects need all being shoved into the reference list of the Assembly-CSharp-firstpass project.

Is there a way I can get Unity/MonoDevelop to let me edit my framework alongside the Unity code that calls it, preserving the framework’s independence from the other Unity C# projects (e.g., Assembly-CSharp)?

I would make a new sln that contains the csproj files from Unity and the the csproj files from your framework. Then you can have a master solution where the code lives side by side. As for getting the framework code into Unity I’d generate a dll and drop that into a plugins directory as you mentioned. You could set the output/build directory in the framework project to be the plugins folder so unity automatically gets updated every time you build.

I can’t remember if Unity will generate it’s own csproj files for you, so you might want to grab Visual Studio Tools For Unity. If you don’t use Visual Studio you can still use the csproj files that get generated (although Microsoft just released a community edition of VS and since VS beats the pants off of MonoDevelop I’d look into it).