How To Use AudioArgs

Back


You can use the AudioArgs static method stored in the ArgsContainer class or a Hashtable to define all the params for a audio manager play method to use. To use the arguments you can do any of the following:

// Using the static Audio Helper class
Play("myClip", ArgsContainer.AudioArgs("position", Vector3.one, "time", 1f));

// Using a Hashtable
Play("myClip", new Hashtable("position", Vector3.one, "time", 1f));

You can also cache a reference for better performance and easy editing like so:

// With Hashtables
// Set in start/awake 
var table = new Hashtable();
table.Add("Position", Vector3.one);
table.Add("Time", 1f);

// When you want to play a clip...
Play("myClip", table);