Created
December 24, 2016 15:04
-
-
Save yunojy/f2e87055ab5ca2ae280d0c3410ba7e13 to your computer and use it in GitHub Desktop.
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
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
[RequireComponent(typeof(AudioSource))] | |
public class PlayAudio : MonoBehaviour { | |
public AudioClip[] audioClips; | |
private AudioSource audioSource; | |
void Start() { | |
audioSource = gameObject.GetComponent<AudioSource>(); | |
} | |
public void RandomPlay() { | |
audioSource.clip = audioClips[Random.Range(0, audioClips.Length)]; | |
audioSource.Play(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment