Playing Audio
Play a Sound from Script
2
Play a Sound
Keep in mind, to play a sound it must be assign in the Soundify script. Look in Setup for more information.
To play a sound, we can either call a sound by its reference as a property in the inspector or by its name directly.
By name:
Soundify.PlaySound("Background Music");By reference:
public Sound sound; Soundify.PlaySound(sound);
Here is an example of a script that plays a sound whenever the game starts:
using UnityEngine;
using ASoundify; // Import the namespace.
public class AudioTest : MonoBehaviour {
public Sound sound; // Property in the inspector.
private void Start() {
Soundify.PlaySound(sound); // Play the sound on game startup.
}
}Play a Sound automatically using the Audio Player
The Audio Player script lets you add the reference to play a sound automatically without coding.
3
Change the Sound to the Sound you want to play
The sound must be assigned in the Soundify script. See Setup for more information.
4
Last updated


