using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SoundMananger : MonoBehaviour
{
public static SoundMananger instance;
//静态类代码
public AudioSource AudioSource;
[SerializeField]
public AudioClip jumpAudio, hurtAudio, cherryAudio;
private void Awake()
{
instance = this;
//让这个实例等于他自己本身,就可以让他代表整个SoundMananger的所有东西
}
public void JumpAudio()
{
AudioSource.clip = jumpAudio;
AudioSource.Play();
}
public void HurtAudio()
{
AudioSource.clip = hurtAudio;
AudioSource.Play();
}
public void CherryAudio()
{
AudioSource.clip = cherryAudio;
AudioSource.Play();
}
}
06-19
1666
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-15
08-15