Skip to content

AudioManager

高凯 edited this page Dec 31, 2017 · 2 revisions

Introduction

Use AudioManager, a line of code to play the game sound

  • Make sure the music is in the Resources directory and generate the package settings correctly

API

AudioManager
static AudioSource PlayMusic2D (string musicName, bool isLoop) Play a 2D music
static AudioSource PlaySound2D (string soundName, float pitch, bool isLoop = false) Play a 2D sound effect
static void PlaySound2D (string soundName, float delay) Play a 2D sound effect with variable pitch
static AudioSource PlaySound3D (string soundName, GameObject gameObject) Play a 3D sound, passing in an object to play the sound
s_GlobalVolume global volume, ranging from 0 to 1, multiplied by sound volume and music volume
s_MusicVolume music volume, ranging from 0 to 1
s_SoundVolume sound volume, ranging from 0 to 1

Example

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