Created
May 27, 2014 10:06
-
-
Save edom18/d095f1e6c7893041d9b6 to your computer and use it in GitHub Desktop.
[Unity] Unityで音を再生する ref: http://qiita.com/edo_m18/items/31771c2afc065d764fbf
This file contains 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
// AudioSourceがアタッチされたGameObject | |
void OnCollisionEnter(Collision collision) { | |
AudioSource audioSource = gameObject.GetComponent<AudioSource>(); | |
audioSource.PlayOneShot(anySE); | |
} | |
// あるいは、audioSourceのclipプロパティに設定して再生 | |
void OnCollisionEnter(Collision collision) { | |
AudioSource audioSource = gameObject.GetComponent<AudioSource>(); | |
audioSource.clip = anySE; | |
auidoSource.Play(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment