定义成方法:
using System.Collections; using System.Collections.Generic; using UnityEngine; public class AudioManger : MonoBehaviour { AudioSource au; public AudioClip[] clip = new AudioClip[3]; // Use this for initialization void Start () { au = GetComponent<AudioSource>(); } public void PlayFaShe() { au.clip = clip[0]; au.Play(); } public void PlayHit() { au.clip = clip[1]; au.Play(); } public void PlayOver() { au.clip = clip[2]; au.Play(); } // Update is called once per frame void Update () { } }