InAudio Documentation

Advanced Audio Plugin for Unity

User Tools

Site Tools


quickstart

InAudio Play-A-Sound Quickstart

This is a fast introduction to InAudio of how to play a sound. Check the sidebar for more in-depth info and elaboration.

The basic idea is the create an audio definition and then trigger it from a script on a game object. This makes you easily able to reuse audio different places.

Changes made in runtime are final. This compares to the usual Unity workflow of starting and stopping the game to adjust something. With InAudio you rarely need to stop playing.

The super short guide is:

  1. Add audio via the Audio window.
  2. In a script, add a field of type like public InAudioNode footstepSound;.
  3. Drag-n-drop the audio from the window to the inspector.
  4. Play game and use InAudio.Play(gameObject, footstepSound); to hear it play.

Walkthrough

Open the InAudio window

Create the audio definition

Drag the audio clip to the window

Audio Window

Check if the file name matches

Add the code

Now we need to add a place to play the audio from. To do this we create a simple script that play the sound when the object is enabled.

public InAudioNode soundExample;

InAudio.Play(gameObject, soundExample);

A full example would be

using UnityEngine;

public class PlaySoundExample : MonoBehaviour
{
    public InAudioNode soundExample;
	
	void OnEnable ()
	{
        //Play the audio attached to this game object.
        //Moving the game object will move the sound as well.
	    InAudio.Play(gameObject, soundExample);
	}
}

Drag the audio definition to the inspector

Final look

Now when you play the game, you should hear the audio play!
Remember to make sure the object and the audio listener is close enough to each other to hear.

If you want to take it a step further, try and use events making you able to change everything without touching the inspector after the initial setup.

quickstart.txt · Last modified: 2015/07/11 12:43 by peterolsted