Unity Plugin - GUI slider code exposure plans?


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 :slight_smile:


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.

@mtytel can you elaborate a bit on how to do that? I assume you mean writing these functions in Unity right?

I write a native C++ function like this:

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


Awesome, sounds easy enough, I’ll give that a shot! Thanks for your help :slight_smile:

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.

1 Like