Audio Object

Overview

The Audio Object component is used to define where audio sources are positioned within the scene. Whenever you want to attach audio to an object, you'll need to add an Audio Object component to the game object.

To add an Audio Object component, simply add the SoundMaker/AudioObject script to a Game Object

After adding an AudioObject to a GameObject, the inspector will show property fields for setting the Spatialization mode (see Spatialization Modes), as well as passing a Fabric Audio Source Properties asset.

Scripting

When posting events to Fabric through the scripting API, simply pass the ID of the Audio Object that the event is directed to.

//Starts the "play_music" event from the "Music" FPK.
Fabric.Player.FabricAudioObject audioObject = gameObject.GetComponent<Fabric.Player.FabricAudioObject>();

const string eventName = "play_music";
UInt64 fpkID = FPKInfo.GetFPKID("Music");
Fabric.Player.API.PostEvent(Fabric.Player.FabricPlayer.Instance.fabricPlayerInstanceId,
	fpkID,
	eventName,
	Fabric.Native.EventAction.PlaySound,
    audioObject.ID);
Click to copy

Fabric Audio Source Properties

Fabric Audio Source Properties assets provide a convenient way of applying identical settings across many Audio Objects,  as well as accessing Unity's Audio Source settings if external spatialization is in use (see Spatialization Modes).

You can create a FabricAudioSourceProperties scriptable object in the "Assets/Soundmaker/Audio Source" menu.

In order to use a Fabric Audio Source Properties:

  1. Create the asset by selecting "Audio Source" in the "Assets/Soundmaker/" menu bar dropdown.
  2. Assign the asset to the Audio Source(s) that you would like to apply the settings to.

Notice that changing the Spatialization Mode to "External" reveals an External (Unity Audio Source) settings collapsable menu. 

0 Comments

Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.