- Home /
Use c++ Code in Unity3D
Hi,
I am new to Unity 3D and i am developing a game.I have written a code in c++ using Opencv and the code consist on many files.Now I want to apply the result computed by c++ code to a 3D character. How i can use my c++ code in unity.Please help me.
Remember I am using OpenCV Libraries in my c++ Code.
Thanks!!
You could place your code into a dynamically linked library (DLL). You would still need to refer to it with a little bit of c#.
[Edited - originally had wrong link, oops]
That won't work at all - The DLLs in that link are expected to contain .Net code. Code written in C++ in OpenCV would be native code, it cannot be imported as a DLL in Unity like that.
You can still link to it as a DLL, but it must be called as a plugin in Unity, and you must call its functions with the extern keyword in C#. The link you need is this one:
http://docs.unity3d.com/$$anonymous$$anual/Plugins.html
Notice that plugins are a Pro feature.
Doesn't Android support C++ plugins with the ND$$anonymous$$, at least?
This link may be of interest as a working demo with source:
http://forum.unity3d.com/threads/opencvsharp-for-unity.278033/