- Home /
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
)?
Answer by LessThanEpic · Jan 27, 2015 at 03:09 AM
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).
Thanks for the response. After I posted my question, I ran into another project that does something similar to what you described, although I'm not sure it's pointing the output directory to the Plugins folder -- that sounds like a great addition towards making the process seamless. Thanks for the tip!
And although I'd love to develop using Visual Studio, we're a $$anonymous$$ac-based shop, so I'd have to do it through Parallels or V$$anonymous$$ware. That was less than ideal when I tried it a few months ago, but that was also during the time when $$anonymous$$S had purchased SyntaxTree, and I wasn't able to get UnityVS. $$anonymous$$aybe now it'll be better. I'll try again.