This project has moved and is read-only. For the latest updates, please go here.

Getting this to work in Unity3D?

Dec 4, 2015 at 8:59 PM
Unity3D only really supports managed dlls....

To use an unmanaged dll in Unity3D, you have to use it via code that looks something like this:

// From c++ Dll (unmanaged)
    public static extern float TestMultiply(float a, float b);
Has anyone gotten GraphicsMagick.NET to work with Unity?
Dec 7, 2015 at 8:06 AM
GraphicsMagick.NET is a managed DLL that uses an unmanged DLL so you should be able to use it in Unity3D.
Dec 7, 2015 at 10:54 AM
This would be great. However, from the download of "" I only see one dll named "GraphicsMagick.NET-x64.dll"... not two dlls?

and when I look it up with ILSpy, it says it "contains unmanaged code".

When I try to put the above dll into Unity3D, and look at it in the inspector, Unity3D lists it as "native" rather than managed.

So I assume this is the unmanaged dll you are referring to. But where is the managed dll?
Dec 7, 2015 at 12:30 PM
I apologize for the confusion. I forgot I did not rewrite this library to split the managed and the unmanaged code. I only did this with Magick.NET ( I am now doing a huge rewrite of Magick.NET and when this is done I will also rewrite GhostScript.NET. You might want to give Magick.NET a try because the managed and unmanaged code is already separated there.
Dec 7, 2015 at 12:47 PM
You said you were doing a huge rewrite of "Magick.NET"... did you mean

Because if you are doing the huge rewrite on Magick.NET, maybe I should wait till you are finished?

Dec 7, 2015 at 1:30 PM
No I did mean Magick.NET. I am changing the way the unmanged code is called to make it possible to use Magick.NET and GraphicsMagick.NET in Mono/Core.CLR. Since the API of ImageMagick and GraphicsMagick are very similar I can copy the code from Magick.NET. And then I 'only' have to rename the namespace and remove all the extra features that are only available in ImageMagick.

You can try Magick.NET now. It already has the unmanged code in a separate library so that should work for Unity3D. I still wonder if you could use GraphicsMagick.NET since it is a managed DLL that also contains unmanged code. What is the error that you get when you try to use it in Unity3D?
Dec 7, 2015 at 2:02 PM
If you drop the dll into the /assets folder that Unity makes for you, it doesn't automatically add a reference to it in your project, like it should. and if you try to manually add a reference to it in the project file, then Unity overwrites the project file and removes the reference. So you can't use the dll using a "using GraphicsMagick" statement, because there is no reference to the dll in the project file. You can, however, access the dll if you use a bunch of "[DllImport("")]" statements, but that's a pain to use for such a big and complex library like this. Unity is built on Mono by the way, so if it doesn't work with Mono, it doesn't work with Unity. also, Unity uses Mono's .Net 2.0, and can't use a higher framework than that. So I was excited to see that your stuff works for 2.0. Try to keep it that way, if you want to support Unity. :)

Dec 9, 2015 at 10:09 AM
I will maintain support for .NET 2.0 :) But it might be a while before the new version is available. Does Unity 'tell you' why the reference was not added?
Dec 9, 2015 at 12:54 PM
Nope doesn't tell you.

In the mean time I found some alternatives for drawing lines and bezier curves, which works great in Unity. So I'm okay for now.