|
Hi, I'm currently working on my master thesis and am trying to make everything work in Unity3D. I'm trying to visualize a delaunay tetrahedralization using tetgen software. The point is that tetgen is written in C++. So far, after a lot of effort, I have been able to compile the tetgen source code into a .dll file for use with c# using a c++/cli wrapper. This works fine, that is, untill i try it Unity... I'm getting the following error: "Method contains unsupported native code". Now, as far as my google-fu goes, this is because the dll is unsafe and recompiling the dll using /clr:safe should fix the problem. That, however, is going to be impossible. So my question is: is it possible to circumvent this problem somehow, or some other way I could go about to solve this problem? I would really like to use Unity, but if I can't integrate tetgen with it, I'm gonna start to look for alternatives. I have already lost a lot of time trying to solve this. Also, I don't have Unity pro (too expensive for just a student). Thanks in advance, Sam
(comments are locked)
|

Unfortunately, plugins that you create are only supported in the pro version, which of course you have already found out on your own. This requires the namespace 'using System.Runtime.InteropServices;' and a Dll import call from your C# scripts inside Unity. I don't believe there is any other way, and if there is a way, it would probably eat way too much of your time developing it.
So in short, I think you may be SOL unless you can get a copy of Pro, which in case since you've already created a wrapper, should work fairly seamlessly from that point on. For documentation if you haven't already visited it, point yourself to:
http://unity3d.com/support/documentation/Manual/Plugins.html
There's a student version of Pro for $99, which doesn't allow commercial usage. Seems like a master's thesis should be fine.
@dannyskim : Thank you for your clear and structured answer. I have indeed seen that the pro version can handle plugins better than the indie version can. If you are sure that the pro version can handle dll's containing 'unsafe, unmanaged native' code, I'll try lobbying the university for a license come tomorrow ;). Also, the only examples I've seen using the dll import call in C# are with static external methods. Do you know any good examples where actual classes are imported instead?
Thanks again, you've been very helpful,
Sam
I don't have any examples handy as my work computer isn't with me, but creating JavaVM's is a fairly normal practice inside of Android from Unity. I'll see if I can dig something up that is more relevant to your thesis.