Unity-Technologies/com.unity.multiplayer.samples.coop

Building with -batchmode -nographics emits audio

dylanh724 opened this issue · 1 comments

Describe the bug
Running ./your_game -batchmode -nographics emits audio, when -batchmode shouldn't even be able to emit audio; upon launch, you immediately hear the music theme song loop.

To Reproduce
Steps to reproduce the behavior:

  1. Launch your Linux server via ./your_game -batchmode -nographics
  2. Listen for music

Expected behavior
Should have no music since -batchmode should inherently strip this, already.

Environment (please complete the following information):

  • OS: Linux x64
  • Unity Version: 2022 LTS
  • BossRoom Version: Current clone as of 08/15/2023

Additional context
I have no clue how this happens. On server launch, as a workaround attempt, I tried to grab the Main Camera's AudioListener and disable it #if UNITY_SERVER, but the music still pushes through.

Hi Dylan! Thank you for submitting this issue.

In this case, it is not a bug, things are working as expected. The batchmode argument doesn't turn off audio, it makes the application launch in "headless" mode, which disables display and inputs. (see more details here).

However, if you use the Dedicated Server platform, audio will be turned off by default, along with other optimizations to increase performance (see here for more information, and this page specifically for the difference between headless mode and the dedicated server platform.

As for the UNITY_SERVER define, it is behaving as expected. UNITY_SERVER is defined on builds made with the Dedicated Server platform. If you want to know in the code if you are in batchmode, you can use Application.isBatchMode().

I hope this helps!