Hello,
Lately I tried to make a plugin in Unity and so I wanted to put it in a dll to use it from other projects. I was wondering how you would go about doing it for Linux. If im right you cant use dll on linux but .so and .a files. Can I even compile C# code to Linux library?
I remember reading somewhere that it should be possible. However I’ve only made C/C++ libraries.
DLLs can contain native code (in which case, they’re the equivalent of .so files on Linux/Unix systems).
.NET DLLs however contain bytecode (see CIL / MSIL) that is platform independent by default. Many Assets take this route to avoid exposing their source code (take uSequencer as an example, there’s a normal version with a DLL and a more expensive version with the source code).
To create such a DLL, just compile your code for a compatible target profile (I think it’s still .NET 2.0?). If you use Unity classes in your DLL, link against the correct unity libraries as well.
To use such a DLL, just put it in your Assets directory (or a subdirectory thereof) and it will automatically be used & packaged by Unity and a Reference be added to the generated Visual Studio .csproj files.
Thanks for your reply.
So do I need to compile this DLL in a way that differs in any way from normal DLL? From what I understood I just compile it normally and Unity should be able to use it?
EDIT:
I couldn’t get Unity to automatically use DLLs from the project but when I manually add reference to assemblies it works without problem.
Unity on Linux will use .NET assemblies in the project in exactly the same way that it does on Windows and Mac.
If you encounter a circumstance where this isn’t the case, please file a bug report with your project.