예제 #1
0
        public static void QueueTrack(TrackList.Music track)
        {
            var inst = Instance;

            if (!inst._hasSources)
            {
                while (inst._sources.Count < 2)
                {
                    inst._sources.Add(inst.gameObject.AddComponent <AudioSource>());
                }
                inst._hasSources = true;

                inst._sources[0].volume = Scalar;
            }

            var source = inst._sources[inst._primary];

            if (!source.isPlaying)
            {
                source.clip = track.audio;
                source.loop = track.loops;
                source.Play();
            }
            else
            {
                inst._queue.Enqueue(track);
            }
        }
예제 #2
0
        public static void SwitchTrack(TrackList.Music track)
        {
            var inst = Instance;

            inst._primary = inst._primary == 0 ? 1 : 0;

            var source = inst._sources[inst._primary];

            source.Stop();
            source.clip = track.audio;
            source.loop = track.loops;
            source.Play();
        }