How does LoadPlugin work?


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:

[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.



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.