Use Dedicated Server for content builds
Describes how to create content builds optimized for Dedicated Server builds.
Read time 2 minutesLast updated 20 days ago
You can use Dedicated Server as a target for content directory and AssetBundle builds.
Build content directories
To build content directories for a Dedicated Server, set to while the active build target is a desktop Standalone platform, then call . For example:
EditorUserBuildSettings.standaloneBuildSubtargetStandaloneBuildSubtarget.ServerBuildPipeline.BuildContentDirectory// BuildContentDirectory uses the active build target and subtarget.// Set the Dedicated Server subtarget before you build.EditorUserBuildSettings.standaloneBuildSubtarget = StandaloneBuildSubtarget.Server;var serverContentParameters = new BuildContentDirectoryParameters{ outputPath = "Builds/ServerContent", rootAssetPaths = new[] { "Assets/ServerContentRootAsset.asset" }};BuildPipeline.BuildContentDirectory(serverContentParameters);
After you build the content directory, distribute it alongside the server Player and register it at runtime to load its content. For more information, refer to Load content directories.
Build AssetBundles
To build an AssetBundle to undergo the same Dedicated Server optimizations as discussed for the Player, specify the field in the struct to be when calling the method. Refer to the following example:
subtargetBuildAssetBundlesParametersStandaloneBuildSubtarget.ServerBuildAssetBundleBuildAssetBundlesParameters serverAssetBundleParameters ={ outputPath = /*some example asset path here, not entirely relevant*/, options = BuildAssetBundleOptions.None, targetPlatform = BuildTarget.StandaloneWindows64, //alternately, the MacOS or Linux build targets, any desktop platform subtarget = StandaloneBuildSubtarget.Server};BuildPipeline.BuildAssetBundles(serverAssetBundleParameters);
After you build the AssetBundle, you can load it by a Player at runtime. Refer to Using AssetBundles Natively.