Version: 6000.3
语言: 中文
为专用服务器构建应用程序
桌面无头模式

专用服务器资产包

从 Unity 编辑器版本 2023.1.0a21 开始,您可以将专用服务器优化应用于 AssetBundle。您可以通过脚本构建 AssetBundle。有关构建AssetBundle的更多信息,请参阅有关AssetBundle的部分。

要构建一个AssetBundle,以进行与Player讨论的相同的专用服务器优化,请指定subtarget字段中的BuildAssetBundlesParametersstruct 设置为StandaloneBuildSubtarget.Server调用BuildAssetBundle方法。请参阅以下示例:

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);

构建 AssetBundle 后,您可以在运行时由 Player 加载它。请参阅本机使用AssetBundle。

警告: 虽然 AssetBundle 加载过程会检查 AssetBundle 目标平台是否与播放器的目标平台匹配,但不会检查 AssetBundle 子目标。确保不要加载为非服务器独立玩家构建的AssetBundle。不要尝试加载以专用服务器子目标为目标的 AssetBundle(反之亦然)。

为专用服务器构建应用程序
桌面无头模式