Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save eXponenta/366d92e9621b018f6f546ef623a42e6c to your computer and use it in GitHub Desktop.
Save eXponenta/366d92e9621b018f6f546ef623a42e6c to your computer and use it in GitHub Desktop.
Скрипт позволяющий воспроизводить музыкальные файлы последовательно
using UnityEngine;
using System.Collections;
public class AudioPlayer : MonoBehaviour {
public AudioClip[] Tracks;
public AudioSource Audio_Player;
public int currentTrack = 0;
public bool PlayNow = false;
void Start ()
{
Audio_Player = this.GetComponent<AudioSource> ();
StartCoroutine (NextTrackCheker ());
}
IEnumerator NextTrackCheker()
{
yield return new WaitForSeconds (Audio_Player.clip.length);
currentTrack = (currentTrack + 1) % Tracks.Length;
Audio_Player.clip = Tracks [currentTrack];
Audio_Player.Play ();
}
void Update ()
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment