Search Issue Tracker


Planned for 2021.3.X, 2022.1.X, 2022.2.X, 2023.1.X



Found in





Issue ID




UNITY_SERVER scripting define does not work when switching to Dedicated Server from Windows by script



How to reproduce:
1. Open attached project "" and scene "SampleScene"
2. In Build Settings window, switch to Windows, Mac, Linux platform.
3. In Editor Menu, click Bug -> Repro
4. After the build completes, observe Dedicated Server build's logs

Expected result: "It's a server\!" messages are logged
Actual result: "It's a server\!" messages are not logged

Reproducible with: 2021.2.0b5, 2022.1.0a4
Could not test with: 2019.4.29f1, 2020.3.15f1, 2021.1.16f1 (Dedicated Server functionality not implemented)

Issue does not reproduce when the platform is set to Dedicated Server prior to executing the script.

Issue is not restricted to dedicated server builds. Any time a call to BuildPipeline.BuildPlayer builds a player which platform and subtarget does not match the current active platform in the editor the issue will manifest itself. When platform is manually switched in the Editor's BuildPlayerWindow the problem does not occur because the editor window can detect when there's a mismatch and wait for scripts to be reloaded/recompiled with the new platform compiler macros to start the build. A temporary workaround for users relying on BuildPipeline.BuildPlayer would be to trigger the build a second time if unsure of what was the current active build platform or a reload scripts dialog appears right after the build is completed without the user changing anything.

Comments (1)

  1. ArjanBroosSioux

    Apr 14, 2022 08:33

    How then, do we wait for domain reload from a script run in batch mode?

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.