You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
2.5 KiB
98 lines
2.5 KiB
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
|
|
[RequireComponent(typeof(AudioPlayer))] |
|
public class PlayListTest : MonoBehaviour |
|
{ |
|
public string[] AudioFiles; |
|
|
|
private AudioPlayer audioPlayer; |
|
|
|
void Start() |
|
{ |
|
audioPlayer = GetComponent<AudioPlayer>(); |
|
} |
|
|
|
private void OnGUI() |
|
{ |
|
GUILayout.BeginArea(new Rect(200, 0, 200, 600)); |
|
GUILayout.BeginVertical(); |
|
|
|
GUILayout.Label("播放器测试:"); |
|
|
|
if (GUILayout.Button("排列 1 测试")) |
|
{ |
|
Arrange1(AudioFiles); |
|
} |
|
|
|
if (GUILayout.Button("排列 2 测试")) |
|
{ |
|
Arrange2(AudioFiles); |
|
} |
|
|
|
if (GUILayout.Button("排列 3 测试")) |
|
{ |
|
Arrange3(AudioFiles); |
|
} |
|
|
|
if (GUILayout.Button("排列 4 测试")) |
|
{ |
|
Arrange4(AudioFiles); |
|
} |
|
|
|
if (GUILayout.Button("排列 5 测试")) |
|
{ |
|
Arrange5(AudioFiles); |
|
} |
|
|
|
GUILayout.EndVertical(); |
|
GUILayout.EndArea(); |
|
} |
|
|
|
private void Arrange1(string[] audios) |
|
{ |
|
for (var i = 0; i < AudioFiles.Length; ++i) |
|
audioPlayer.PlayScheduled(AudioFiles[i]); |
|
} |
|
|
|
public void Arrange2(string[] audios) |
|
{ |
|
audioPlayer.PlayList.Add(audios[0], true, true); |
|
audioPlayer.PlayList.Add(audios[1], false, false); |
|
audioPlayer.PlayList.Add(audios[2], false, false); |
|
audioPlayer.PlayList.Add(audios[3], false, false); |
|
|
|
audioPlayer.PlayIndex = 0; |
|
} |
|
|
|
public void Arrange3(string[] audios) |
|
{ |
|
audioPlayer.PlayList.Add(audios[0], true, false); |
|
audioPlayer.PlayList.Add(audios[1], false, false); |
|
audioPlayer.PlayList.Add(audios[2], false, false); |
|
audioPlayer.PlayList.Add(audios[3], false, false); |
|
|
|
audioPlayer.PlayIndex = 1; |
|
} |
|
|
|
public void Arrange4(string[] audios) |
|
{ |
|
audioPlayer.PlayList.Add(audios[0], true, false); |
|
audioPlayer.PlayList.Add(audios[1], false, true); |
|
audioPlayer.PlayList.Add(audios[2], true, false); |
|
audioPlayer.PlayList.Add(audios[3], false, false); |
|
|
|
audioPlayer.PlayIndex = 1; |
|
} |
|
|
|
public void Arrange5(string[] audios) |
|
{ |
|
audioPlayer.PlayList.Add(audios[0], true, false); |
|
audioPlayer.PlayList.Add(audios[1], false, true); |
|
audioPlayer.PlayList.Add(audios[2], false, false); |
|
audioPlayer.PlayList.Add(audios[3], true, false); |
|
|
|
audioPlayer.PlayIndex = 1; |
|
} |
|
} |