Version: Unity 6.0 (6000.0)
语言 : 中文
为专用服务器构建应用程序
桌面无头模式

专用服务器 AssetBundle

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

要构建 AssetBundle 以进行与运行版相同的专用服务器优化,请在调用 BuildAssetBundle 方法时在 BuildAssetBundlesParameters 结构中指定要 StandaloneBuildSubtarget.Serversubtarget 字段。请参考以下示例:

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 后,可由运行版相在运行时加载。请参考本地使用 AssetBundle

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

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