Scripting API Reference

10. Scripting API Reference

The FMOD Studio Unity Integration exposes the full FMOD Core and Studio API's in C#.

The Studio API is used to playback and control events created in the FMOD Studio tool.

The Core API is for playing back sounds directly as well as advanced control of event playback.

The Runtime Manager API provides helpers for the most common operations in writing Unity game components that use FMOD Studio Events.

10.1 Basics

When the RuntimeManager initializes, it creates a StudioSystem and a CoreSystem. You can use any and/or all of these to access the API's.

var studioSystem = FMODUnity.RuntimeManager.StudioSystem;
FMOD.Studio.CPU_USAGE cpuUsage;
studioSystem.getCPUUsage(out cpuUsage);

var coreSystem = FMODUnity.RuntimeManager.CoreSystem;
uint version, buildnumber;
coreSystem.getVersion(out version, out buildnumber);

10.2 Browser UI in Unity Inspector

You can access the custom FMOD UI for picking events, banks and global parameters by using one of the following:

10.2.1 Events

Use the EventReference type to hold a reference to an event.

public class EventReferenceTest : MonoBehaviour
{
    public FMODUnity.EventReference MyEvent;
}

You will be presented with this UI:

Event Reference

10.2.2 Banks

Use the attribute "[FMODUnity.BankRef]" on any string property you are using to hold the path of a bank.

public class BankRefTest : MonoBehaviour
{
    [FMODUnity.BankRef]
    public string MyBank1;
}

You will be presented with this UI:

Event Reference

10.2.3 Global Parameters

Use the attribute "[FMODUnity.ParamRef]" on any string property you are using to hold the path of a global parameter.

public class ParamRefTest : MonoBehaviour
{
    [FMODUnity.ParamRef]
    public string MyParam1;
}

You will be presented with this UI:

Event Reference