Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
BuildPipeline.BuildPlayer 编译播放器
# [BuildPipeline](BuildPipeline.html).BuildPlayer 编译播放器 static function *BuildPlayer* (*levels* : string[], *locationPathName* : string, *target* : [BuildTarget](../Editor_Enumerations/BuildTarget/BuildTarget.html), *options* : BuildOptions) : string ### Parameters**参数** * *levels* The scenes to be included in the build. If empty, the currently open scene will be built. Paths are relative to the project folder (Assets/MyLevels/MyScene.unity). 包含在编译中的场景,如果为空,当前打开的场景将被编译。路径相对于项目文件夹(Assets/MyLevels/MyScene.unity). * *locationPathName* The path where the application will be built. Must include any necessary file extensions, like .exe, .app, .unity3d or .wdgt. 将被编译应用程序的路径,必须包括所有必要的文件扩展名。 * *target* The [BuildTarget](../Editor_Enumerations/BuildTarget/BuildTarget.html) to build. 要编译的 BuildTarget。 * *options* Additional [BuildOptions](../Editor_Enumerations/BuildOptions/BuildOptions.html), like whether to run the built player. 添加编译选项,例如是否运行那种播放器。 *Returns* string - an error message if an error occurred. 如果产生错误,返回一个错误消息。 *Description* 描述 Builds a player (Unity Pro only). 生成一个播放器(仅用于 Unity Pro)。 Use this function to programatically create a build of your project. 使用这个函数通过编程来创建一个你的项目编译。 ``` // Build a streamed unity3d file. This contain one scene that can be downloaded // on demand and loaded once it's asset bundle has been loaded. //生成一个流unity3d文件。这包含一个场景,可以按需下载和加载,一旦它的资源包已被加载。 @MenuItem ("Build/BuildWebplayerStreamed") static function MyBuild(){ var levels : String[] = ["Assets/StreamedScene1.unity", "Assets/StreamedScene2.unity", "Assets/StreamedScene3.unity"]; BuildPipeline.BuildPlayer( levels, "StreamedWebplayer.unity3d", BuildTarget.WebPlayer, BuildOptions.BuildAdditionalStreamedScenes); } ``` When [BuildOptions.BuildAdditionalStreamedScenes](Editor_Enumerations/BuildOptions/BuildOptions.BuildAdditionalStreamedScenes.html) is used, the resulting file will not be a traditional player. The result will be a file that can be dynamically loaded in at runtime. In order to dynamically load one of these extra scenes in, download the file using the [WWW](../WWW/WWW.html) class, and make sure to call [WWW.assetBundle](../WWW/WWW.assetBundle.html). You don't actually have to call [AssetBundle.LoadAll](../WWW/WWW.LoadAll.html)(). As soon as you assigned [WWW.assetBundle](../WWW/WWW.assetBundle.html) to a variable, from that point on, you can use regular [Application.LoadLevel](../WWW/WWW.LoadLevel.html)() and [Application.LoadLevelAdditive](../Application/Application.LoadLevelAdditive.html)() calls to load the level as you would usually do. 当 [BuildOptions.BuildAdditionalStreamedScenes](Editor_Enumerations/BuildOptions/BuildOptions.BuildAdditionalStreamedScenes.html) 被使用,生成的文件将不是传统的播放器。其结果将是一个可以在运行时动态加载的文件。为了动态加载另一个场景,使用 [WWW](../WWW/WWW.html) 类下载文件,并确保调用了 [WWW.assetBundle](../WWW/WWW.assetBundle.html)。你实际上并不需要调用 [AssetBundle.LoadAll](../WWW/WWW.LoadAll.html)()。只要你指定 [WWW.assetBundle](../WWW/WWW.assetBundle.html) 到一个变量,通常会这样做,可以使用普通的 [Application.LoadLevel](../WWW/WWW.LoadLevel.html)()和 [Application.LoadLevelAdditive](../Application/Application.LoadLevelAdditive.html)() 调用来加载关卡。 ``` // Build a streamed unity3d file. This contain one scene that can be downloaded // on demand and loaded once it's asset bundle has been loaded. //生成一个流unity3d文件。这包含一个场景,可以按需下载和加载,一旦它的资源包已被加载。 BuildPipeline.BuildPlayer( ["Assets/DynamicallyLoadedScene.unity"], "DynamicallyLoadedScene.unity3d", BuildTarget.WebPlayer, BuildOptions.BuildAdditionalStreamedScenes); ```
da
2022年5月17日 13:11
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码