Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save James-Frowen/9457379aeae036627b9a25790f9bdc51 to your computer and use it in GitHub Desktop.
Save James-Frowen/9457379aeae036627b9a25790f9bdc51 to your computer and use it in GitHub Desktop.

Unity has changes how to create server build in 2021

Building from script

replace:

if (serverBuild)
    buildOptions |= BuildOptions.EnableHeadlessMode;

with:

var options = new BuildPlayerOptions();
if (serverBuild)
    options.subtarget = (int)(serverBuild ? StandaloneBuildSubtarget.Server : StandaloneBuildSubtarget.Player),

Running in Editor

UNITY_SERVER might now be defined in editor

replace:

#if UNITY_SERVER

with:

#if !UNITY_EDITOR && UNITY_SERVER

replace:

#if !UNITY_SERVER

with:

#if UNITY_EDITOR || !UNITY_SERVER
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment