Forked from Dranser/gist:62639ea75d62d2d8363816e783abaadf
Last active
August 7, 2016 18:13
-
-
Save eXponenta/366d92e9621b018f6f546ef623a42e6c 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
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