创建一个AudioSource组件,拖一个mp3组件到这个组建上
新建一个脚本,拖audiosource到audiosource的声明上
using UnityEngine;
using System.Collections;
public class audios : MonoBehaviour {
public AudioSource music;
void Start () {
//music.Play();
}
void OnGUI()
{
if (GUI.Button(new Rect(100, 100, 200, 100),"play"))
{
music.Play();
}
}
// Update is called once per frame
void Update () {
}
}