Reputation: 11
I want to gather the played AudioClip.
We can get the source name using the script below, but I can't get the clip. (Log says the clip is null)
How can I get the played clip and its name?
public AudioSource source;
public AudioClip[] clips; //we have clip1 and clip2
void Update()
{
if(Input.GetKeyDown(KeyCode.Space)
{
int i = Random.Range(0, 1);
source.PlayOneShot(clips[]);
}
if(source.isPlaying)
{
Debug.Log(source.gameObject.name); //OK
Debug.Log(source.clip.name); //Not OK...(null)
}
{
I want to use the clip in other system.
Upvotes: 1
Views: 21