Skip to content

Instantly share code, notes, and snippets.

@ssavva05
Forked from bowlandcereal/AudioManager
Created March 17, 2019 19:54
Show Gist options
  • Save ssavva05/5dff114ddfa090af58b90c34ae7de871 to your computer and use it in GitHub Desktop.
Save ssavva05/5dff114ddfa090af58b90c34ae7de871 to your computer and use it in GitHub Desktop.
public class AudioManager : MonoBehaviour {
// Your audio clip
public AudioClip MusicClip;
// the component that Unity uses to play your clip
public AudioSource MusicSource;
// Use this for initialization
void Start () {
MusicSource.clip = MusicClip;
}
// Update is called once per frame
void Update ()
{
if (Input.GetKeyDown(KeyCode.Space))
MusicSource.Play();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment