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.
33 lines
719 B
33 lines
719 B
1 year ago
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
[RequireComponent(typeof(AudioPlayer))]
|
||
|
public class AudioPlayerTest : MonoBehaviour
|
||
|
{
|
||
|
public string AudioFile;
|
||
|
|
||
|
private AudioPlayer audioPlayer;
|
||
|
|
||
|
void Start()
|
||
|
{
|
||
|
audioPlayer = GetComponent<AudioPlayer>();
|
||
|
}
|
||
|
|
||
|
void OnGUI()
|
||
|
{
|
||
|
GUILayout.BeginArea(new Rect(200, 0, 200, 600));
|
||
|
GUILayout.BeginVertical();
|
||
|
|
||
|
GUILayout.Label("播放器测试:");
|
||
|
|
||
|
if (GUILayout.Button("开始播放"))
|
||
|
audioPlayer.Play(AudioFile);
|
||
|
|
||
|
if (GUILayout.Button("停止播放"))
|
||
|
audioPlayer.Stop();
|
||
|
|
||
|
GUILayout.EndVertical();
|
||
|
GUILayout.EndArea();
|
||
|
}
|
||
|
}
|