EditorUserBuildSettings.activeBuildTarget return wrong active build target

In Unity 2021 and 2022. When your build target is set to Dedicated Server, EditorUserBuildSettings.activeBuildTarget will return Standalone instead.

This is wrong as there should be a way to know if you are on Standalone or Dedicated server from Editor script since the two targets have different player settings (in 2020 and before it was fine because they shared the same player settings). So that editor script editing active player settings change the right settings.

Is there another function to check if the activeBuildTarget is DedicatedServer? Or this needs to be fixed?

The same problem

You need to use Unity - Scripting API: EditorUserBuildSettings.standaloneBuildSubtarget