Skip to content

Instantly share code, notes, and snippets.

@bowlandcereal
Created February 3, 2017 04:44
Show Gist options
  • Save bowlandcereal/73f70cbda205241f95a6e77aefbd7241 to your computer and use it in GitHub Desktop.
Save bowlandcereal/73f70cbda205241f95a6e77aefbd7241 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