so, currently Parameters in Unity Native Audio Plugins can only be controlled from code within Unity, when not using a custom GUI.
My question is: are there any plans on integrating that down the road?
A lot of ideas I have rely on a custom GUI, not for the flashy looks, but for the functionality.
Let me give you one example:
A simple convolution plugin where the user should be able to choose a sample for the convolution. The plugin would need some sort of interface, where the user can do that, be it a āLoad Fileā dialog, or a drag and drop field or whatever. If I donāt provide a GUI, then thereās only Unity Sliders, which canāt accomodate that.
So Iām basically stuck between having more interaction possibilities than what sliders can provide and on the other hand being able to control the plugin from code.
Controlling the plugin parameters through code seems like an immensely important thing for a plugin that can be hosted within a game engine, but having only sliders to work with is very limiting in what can be achieved. Please correct me if Iām wrong and there are ways to accomplish what Iām describing.
Still, overall Iām super thrilled about native Unity plugins, they came along just at the right moment when I have to write DSP in Unity for a university project. This will make things so much easier, no more fighting with C# and the AudioFilterRead method and all that stuff
You can create your own native functions that set parameters instead of going through Unityās āExpose Parameterā API which I think is really cumbersome anyway.
I pass a channel value (similar to MIDI) to map control changes to the correct instances.
extern "C" UNITY_AUDIODSP_EXPORT_API bool SetParameter(int channel, int paramater_id, float value) {
// Get all instances with matching channel and set the parameters
}
And reference the native function from C# like this:
#if UNITY_IOS
[DllImport("__Internal")]
#else
[DllImport("AudioPluginYourApp")]
#endif
public static extern void SetParameter(int channel, int parameter_id, float value);
Then you can call the C# handle with a channel, parameter_id and value.
I maintain a list of all instances in the native code that I go over when the native C++ function is called. Itās not pretty but it beats Unityās āExpose Parameterā API.
Love this. The problem Iām having at the moment is with extern (Iām a bit of a noob). Getting ālinkage specification is not allowedā. How did you make your way around that? Sorry for being a bit thick.