You can customize how Unity displays the parameter descriptions you create in your native DSP plug-in. By default, Unity displays these parameter descriptions as sliders. However, some plug-insA set of code created outside of Unity that creates functionality in Unity. There are two kinds of plug-ins you can use in Unity: Managed plug-ins (managed .NET assemblies created with tools like Visual Studio) and Native plug-ins (platform-specific native code libraries). More info
See in Glossary need more complex user interaction that allows the user more control.
You can use C# to customize the GUI and replace the default sliders. To access examples of custom GUIs:
In the SDK, navigate to NativeAudioPlugins-master\GUICode\AudioPluginDemoGUI
.
Open the AudioPluginDemoGUI.sln
project in Visual Studio, or open the GUI files in this folder in another IDE.
This page gives an overview of steps to take to create a GUI for your native audio DSP plug-in.
After Unity loads the native plug-inA platform-specific native code library that is created outside of Unity for use in Unity. Allows you can access features like OS calls and third-party code libraries that would otherwise not be available to Unity. More info
See in Glossary DLL files and registers the contained audio plug-ins, it searches for corresponding GUI files that match the names of the registered plug-ins.
To make sure Unity links your custom GUI to your plug-in:
Open your custom GUI class.
Make sure your GUI class inherits from IAudioEffectPluginGUI
.
Override the Name property of your class so it is the same as your plug-in. This is what Unity uses to link your files, not the DLL file name. For example:
public override string Name
{
get { return "Demo Equalizer"; }
}
The example audio plug-in SDK has a few examples of different ways you can present your parameters, including filter curves. You can use any of these examples in your project.
In your custom GUI class, create variables that you want to control via user interaction. For example:
private float masterGain;
private float lowGain, midGain, highGain;
Refer to the example projects for ideas for UI(User Interface) Allows a user to interact with your application. Unity currently supports three UI systems. More info
See in Glossary elements and
create your preferred UI elements.
You need to define how the parameters in your plug-in relate to your GUI customizations. The OnGUI(IAudioEffectPlugin plugin)
boolean function receives a handle to the native plug-in and then uses it to read and write parameters the native plug-in has defined. To bind your parameters:
Find the OnGUI(IAudioEffectPlugin plugin)
boolean function in your GUI class.
Use plugin.GetFloatParameter
to read each parameter from your native plug-in and map it to your GUI variable.
plugin.GetFloatParameter("MasterGain", out masterGain);
This returns true if a parameter is found.
Use plugin.SetFloatParameter
to set the value of your plug-in parameter to the current value of your GUI variable.
plugin.SetFloatParameter("MasterGain", masterGain);
This returns true if the parameter is found.
To avoid duplicate or contradicting parameter definitions in the native DSP and GUI code, use the plugin.GetFloatParameterInfo
function.
plugin.GetFloatParameterInfo("NAME", out minVal, out maxVal, out defVal);
If your OnGUI function returns true, the InspectorA Unity window that displays information about the currently selected GameObject, asset or project settings, allowing you to inspect and edit the values. More info
See in Glossary shows the default UI sliders below the custom GUI. This is useful for GUI development because:
All the parameters are available while you develop your custom GUI.
You can check that the right actions result in the expected parameter changes.
To import your GUI for your plug-ins into Unity, refer to Use your native DSP plug-in and GUI in Unity.