I am interested in using utilising third-party libraries in Unity Free.

I know Unity can use managed libraries as assets, but only the Pro version supports using native libraries (DllImport within scripts). This thread, however suggests that it is possible to import DLLs in the free version.

I would like to utilise native libraries (as a hobbyist I cannot afford the Pro version), but want to do it the supported way so I don't have to worry about Unity 'fixing' this hole if that is what it is.

Is there any supported way to use native libraries with Unity free (in other words, is the method described in that thread using DllImport safe and reliable, or is it a workaround that might be patched away)?

  • \$\begingroup\$ You could consider using a managed C++ dll to communicate between the two if unity doesn't support native C++ in their free distribution. \$\endgroup\$
    – Evan
    Mar 5 '13 at 23:29
  • \$\begingroup\$ Late reply.. but why not try it yourself? You can build your .exe with Unity free and have it load your native code DLL fine. Unity Pro only seems to restrict plugins when they reside in the Asset/Plugins. This work around isn't ideal, but could do the trick. \$\endgroup\$
    – Fabien
    Jun 26 '13 at 16:30
  • \$\begingroup\$ @Fabien, I definitely would to see if it worked - actually from what I have read I am pretty sure it would work - but theme of the question was meant to be more... is it going to work in 2 years time when Unity XYZ is released. :) \$\endgroup\$
    – sebf
    Jun 30 '13 at 18:55

You can use DllImport in compiled managed DLLs which are referenced in your C# code.

However you will not be able to use your resulting product on any system other than windows.

For additional information see this thread.

  • 1
    \$\begingroup\$ This answer would be much better if you included an example of how to do so, even if its from your linked thread, as external links are subject to link-rot and that content eventually may become unavailable. \$\endgroup\$
    – user1430
    Dec 20 '13 at 16:45
  • \$\begingroup\$ Surely Googling DLLImport provides more than enough examples? \$\endgroup\$
    – Basic
    Aug 20 '16 at 4:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .