1.调用unity包
using UnityEngine;
using System.Collections;
2.efxSource:音效
musicSource:背景音乐
instance:单例
lowPitchRange:音高(低)
highPitchRange:音高(高)
public class SoundManager : MonoBehaviour
{
public AudioSource efxSource; //Drag a reference to the audio source which will play the sound effects.
public AudioSource musicSource; //Drag a reference to the audio source which will play the music.
public static SoundManager instance = null; //Allows other scripts to call functions from SoundManager.
public float lowPitchRange = .95f; //The lowest a sound effect will be randomly pitched.
public float highPitchRange = 1.05f; //The highest a sound effect will be randomly pitched.