Version: 2022.3
Language : English
Build your application for Dedicated Server
Desktop headless mode

Dedicated Server AssetBundles

You can apply the Dedicated Server optimizations to AssetBundles starting in Unity Editor version 2023.1.0a21. You can build an AssetBundle through scripting. Refer to the section on AssetBundle for more information on building AssetBundles in general.

To build an AssetBundle to undergo the same Dedicated Server optimizations as discussed for the Player, specify the subtarget field in the BuildAssetBundlesParameters struct to be StandaloneBuildSubtarget.Server when calling the BuildAssetBundle method. Refer to the following example:

BuildAssetBundlesParameters 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.

Warning: While the AssetBundle loading process checks if the AssetBundle target platform matches the target platform of the player, it doesn’t check the AssetBundle subtarget. Make sure to not load an AssetBundle built for a non-server standalone player. Don’t try to load an AssetBundle that targets the Dedicated Server subtarget (or vice-versa).

Build your application for Dedicated Server
Desktop headless mode
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961