AudioToolKit的简单介绍及教程
原创文章如需转载请注明:转载自风宇冲Unity3D教程学院
1 播放AudioItem:
AudioController.Play( "MyUniqueAudioItemName" )
2 播放唯一的Music:
AudioController.PlayMusic( "MusicAudioItemName" )
注意:AudioController.Play播放的音效是互不影响,可以叠加的,而AudioController.PlayMusic只播放当前的唯一音乐,并且自动处理淡入淡出等。
3 播放列表:
PlayList实际上就是string数组,PlayList里的音乐可以在不同的Category里。
- void SetAndPlay()
- {
- string[] playList = new string[2];
- playList[0] = "01";
- playList[1] = "02";
- AudioController.SetMusicPlaylist(playList);
- AudioController.PlayMusicPlaylist();
- }
4 更多例子:
AudioController.Play( "MySoundEffect1" );
AudioController.Play( "MySoundEffect2", new Vector3( posX, posY, posZ ) );
AudioController.PlayMusic( "MusicTrack1" );
AudioController.SetCategoryVolume( "Music", 0.5f );
AudioController.PauseMusic();
【改变Pitch】
(1) 用unity自带的AudioSource里的pitch改
- AudioObject obj = AudioController.Play("01");
- obj.audio.pitch = 0.3f;
(2) 使用AudioToolKit的初始pitch设置(下图的Pitch Shift), 或者随机pitch设置(下图的Random Pitch),均以
半音程为1个单位。
(3)
AudioObject obj = AudioController.Play("Sound1");
obj.audio.pitch = AudioObject.TransformPitch(10);