Using External DLLs for Unity

We have been having a conversation about using external DLLs with unity as compared to using scripts inside the projects. I’ve put together my own list of pros/cons and would be interested to know how others deal with this topic:

For me the pros and cons are:

pros for external DLLs:

  1. Organization
  2. Reusability
  3. Testing
  4. Automation
  5. Conflicts resolve easily
  6. Properly structured code results in better structured projects. Everything just works smoother and is easier to debug.

cons:

  1. Unable to debug using built-in debugging tools (must use your own). We have our own debug console that is more useful for me regardless.
  2. Setup for a team takes longer. I can setup a large project in about a day now - with full automation and build support - it was much longer the first time.
  3. Does require shedding some Unity practices to decouple logic from objects in a meaningful way.
  4. DLL scripts can’t be called with executeMethod command argument - so you must create a wrapper for those.
  5. Without proper setup you have to deal with binary conflicts a lot.

We use external DLLs and have been very happy with the results - but it does take some design change and extra setup to get working in a very good way.

Please share any thoughts

Unity runs the MonoRuntime and I’ve been wanting to use an external DLL so I can run it in the .Net runtime. If only I knew how.

One idea. Starting a new process and communicate between the MonoRuntime and the .Net runtime via IPC.

I would really only use dlls for libraries that don’t use unity apis. I have a dll that i made and it is much more difficult. You listed not being able to debug. You can debug. I did it from my library in mono develop. You need to build the dll and the debug symbols and put both of them in you unity project in the same folder. Then attach mono develop to unity and play inside unity.

You should check out the unity test package they recently released in the asset store. It’s free and let’s you do nunit testing inside unity easily.