# How does LoadPlugin work?

**URL:** https://qa.fmod.com/t/how-does-loadplugin-work/11391
**Category:** Unity
**Created:** [April 8, 2014, 6:44pm UTC](https://qa.fmod.com/t/how-does-loadplugin-work/11391 "2014-04-08T18:44:54Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![baba](https://avatars.discourse-cdn.com/v4/letter/b/a5b964/32.png) [@baba](https://qa.fmod.com/u/baba)
#### Post date: [April 8, 2014, 6:44pm UTC](https://qa.fmod.com/t/how-does-loadplugin-work/11391/1 "2014-04-08T18:44:54Z")

</div>

Hello,

I am experimenting with a custom procedural audio synth and I have a C library that I am trying to make available for Unity (and then fmod at a later stage).  
I managed to get my C library in unity as a plugin, and I can call it from C# but in order to do that I have to do [DllImport] for every and each of my API function i want to expose.

I am not sure I understand it correctly but looking at your fmod.cs code in your unity plugin it seems like you manage to make all of your fmod C/C++ API fiunctions available to c# by just using one single [DllImport] as follows:

```auto
[DllImport (VERSION.dll)]
		private static extern RESULT FMOD_System_LoadPlugin(IntPtr system, string filename, ref uint handle, uint priority);
```

If i understand correctly, your FMOD::System class has a member function named loadPlugin that manages to automatically expose all the functions in your C++ API to C#.  
I am not a very experienced programmer, but I would like to do the same thing with my C API functions. (ie make them all available to C# scripts without using [DllImport] for each of them)

How should I do it? (i.e how does loadPlugin works?).  
Any hint or pointer to docs on the web is welcomed since I am not a very experienced programmer.

Thanks,

baba

---

<div class="post-metadata">

### Author: ![Guest](https://avatars.discourse-cdn.com/v4/letter/g/8dc957/32.png) [@Guest](https://qa.fmod.com/u/Guest)
#### Post date: [April 9, 2014, 6:33am UTC](https://qa.fmod.com/t/how-does-loadplugin-work/11391/2 "2014-04-09T06:33:04Z")

</div>

The fmod.cs file in the Unity integration exposes only a small subset of the FMOD Low Level API, so it doesn’t have many [DllImport] declarations. I think you may have missed the fmod\_studio.cs file, which contains a [DllImport] declaration for every function in the FMOD Studio API. I think using one [DllImport] declaration per function is the way to go for your plugin.
