x


Method contains unsupported native code

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

more ▼

asked Dec 04 '11 at 09:57 PM

SamAgten gravatar image

SamAgten
16 3 3 4

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

Dec 04 '11 at 10:14 PM dannyskim

There's a student version of Pro for $99, which doesn't allow commercial usage. Seems like a master's thesis should be fine.

Dec 04 '11 at 11:22 PM Eric5h5

@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

Dec 04 '11 at 11:26 PM SamAgten

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.

Dec 04 '11 at 11:44 PM dannyskim
(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x246
x9

asked: Dec 04 '11 at 09:57 PM

Seen: 1058 times

Last Updated: Dec 04 '11 at 11:44 PM