Created
February 3, 2017 04:44
-
-
Save bowlandcereal/73f70cbda205241f95a6e77aefbd7241 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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