#building a Netcode Client With `BuildPipleline.BuildPlayer`

1 messages · Page 1 of 1 (latest)

shut kernel
#

been trying to create a client only build via a c# script using BuildPipeline.BuildPlayer().
I can't figure out what I need to pass as the BuildPlayerOptions.
these are my current options (tried a few variations of them but nothing did the job):

      var buildPlayerOptions = new BuildPlayerOptions
      {
        locationPathName = $"C:/builds/{subpath}/build.exe",
        targetGroup = BuildTargetGroup.Standalone,
        target = BuildTarget.StandaloneWindows64,
        subtarget = (int)StandaloneBuildSubtarget.Player,
        scenes = GetScenesFromDefaultBuildWindow()
      };

I even tried to pass the options that the build window should produce by using BuildPlayerWindow.DefaultBuildMethods.GetBuildPlayerOptions() but that produces a client & server build too. everything works as expected if I build via the build window -> it does just include the client.
What values do I need to pass to BuildPipeline.BuildPlayer() to get a client only build?

proud glade
#

Hey Dot! It's in your ProjectSettings > Entities > Netcode Client Target dropdown .
You can modify it by modifying NetCodeClientSettings.ClientTarget, which (IIRC) can be fetched via DotsGlobalSettings.Instance.GetClientSettingAsset().AsScriptableObject() casted to a NetcodeClientSettings.

shut kernel
#

hey Niki. Thanks for your quick reply. I've already set the type to 'Client' but the call to BuildPlayerWindow.DefaultBuildMethods.GetBuildPlayerOptions() still creates BuildPlayerOptions that produce a client & server build.

After digging through some code (you mentioning DotsGlobalSettings.Instance put me on the right track) I think the issues is caused by how the build system handles the class EntitySceneBuildPlayerProcessor which is provided the Entities package. This class gets ignored when using the GetBuildPlayeOptions() method. It would provide the scripting define UNITY_CLIENT via the class NetCodeClientSettings.ClientSettings which results in a client only build. So i guess this is more of a build system / entities package issue than directly netcode related.

As a workaround I can either copy parts of the code of the EntitySceneBuildPlayerProcessor or I can hard code the correct BuildPlayerOptions values. Nonetheless it is imo confusing that the EntitySceneBuildPlayerProcessor only provides default BuildPlayerOptions when using the build window and not if I call BuildPlayerWindow.DefaultBuildMethods.GetBuildPlayerOptions().

Should I report this as a bug / unexpected behavior of the build system?