Skip to content

音频管理器

高凯 edited this page Dec 31, 2017 · 1 revision

介绍

使用AudioManager,一行代码播放游戏音效

  • 确保音乐在Resources目录下,并正确生成打包设置

API

AudioManager
static AudioSource PlayMusic2D(string musicName, bool isLoop) 播放一个2D音乐
static AudioSource PlaySound2D(string soundName, float pitch, bool isLoop = false ) 播放一个2D音效
static void PlaySound2D(string soundName,float delay ) 播放一个2D音效, 可变音调
static AudioSource PlaySound3D(string soundName, GameObject gameObject) 播放一个3D音效,传入一个对象用以播放声音
s_GlobalVolume 全局音量,范围从0到1,与音效音量和音乐音量是相乘关系
s_MusicVolume 音乐音量,范围从0到1
s_SoundVolume 音效音量,范围从0到1

示例

AudioManager.PlayMusic2D("funnyLaugh", false);
Clone this wiki locally