Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

What is the BuildTargetGroup for the Dedicated Server platform?

Discussion in 'Multiplayer' started by dclipca, Apr 19, 2023.

  1. dclipca

    dclipca

    Joined:
    Oct 30, 2021
    Posts:
    22
    There seems to be a BuildTargetGroup enum for every platform except for Dedicated Server. What is the BuildTargetGroup for the Dedicated Server platform?

    One use case is to switch the editor into the Dedicated Server platform programatically, as a part of some script:
    Code (CSharp):
    1. var buildTarget = BuildTarget.Android;
    2. SwitchActiveBuildTarget(buildTarget);
    but I cannot find either a BuildTarget or BuildTarget group for the Dedicated Server platform (Unity - Scripting API: BuildTarget (unity3d.com), Unity - Scripting API: BuildTargetGroup (unity3d.com))
     
    Last edited: Apr 19, 2023
  2. cristianm_unity

    cristianm_unity

    Unity Technologies

    Joined:
    Oct 16, 2018
    Posts:
    234
    Hey! Dedicated Server build target group is Standalone. That is because Dedicated Server is a subtarget of the Standalone target.

    So switching to Dedicated Server would be something like
    Code (CSharp):
    1. EditorUserBuildSettings.standaloneBuildSubtarget = StandaloneBuildSubtarget.Server;
    2. EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.StandaloneWindows64);
    On the other hand, if you want to define some player settings specifically for Dedicated Server you need to use the NamedBuildTarget:
    Code (CSharp):
    1. PlayerSettings.SetScriptingBackend(NamedBuildTarget.Server, ScriptingImplementation.IL2CPP);
     
    dclipca likes this.
  3. dclipca

    dclipca

    Joined:
    Oct 30, 2021
    Posts:
    22
    Thank you @cristianm_unity, very cool.