Game Development Reference
In-Depth Information
Native plugins (Pro only)
The last integration approach is the one that takes the most effort but can have the most
benefit—it also has the advantage of being the most reusable.
If you are running the Pro version of Unity, you can import the native C++ DLLs and their
corresponding functionalities into Unity3D. Generally, this is used to access a third-party
function library such as Physics and Math or Physics. Some assets on the Asset store also
ship with native plugins to enable them to be as fast as possible (and as a by-product, they
ensure that you cannot copy their code from a compiled library):
The plugin, once created, should be placed in the Plugins folder mentioned previously,
and then called from the code as follows:
[DllImport ("PluginName")]
private static extern float FooPluginFunction ();
This effectively gives you a pointer to the code that will run outside of Unity3D. By call-
ing the previous function, Unity interprets this and passes it on to the external library to
process and return from.
The advantage of using the native plugins is mainly speed. You get direct access to a nat-
ive platform and all the performance boosts it provides. It is by far the most complicated
way to enable such features, and deciding on using it would simply come down to if you
need that level of power.
Search WWH ::




Custom Search