S&box Wiki

Revision Difference

menu_music#550123

<cat>UI.GameMenu</cat>⤶ <title>Menu Music</title>⤶ ⤶ # Menu Music⤶ ⤶ It's possible to play an mp3 in the background of your menu. The problem you might face is that it will play over the game too. You can solve this with a bit of logic in your menu panel to manage the music better.⤶ ⤶ ```⤶ public override void Tick()⤶ {⤶ base.Tick();⤶ UpdateMusic();⤶ }⤶ ⤶ SoundHandle MenuMusic;⤶ ⤶ void UpdateMusic()⤶ {⤶ if ( Game.InGame )⤶ {⤶ MenuMusic.Stop( true );⤶ return;⤶ }⤶ ⤶ if ( !MenuMusic.IsPlaying )⤶ {⤶ MenuMusic = Audio.Play( "ui/menu_music.sound" );⤶ }⤶ }⤶ ```⤶ ⤶