Unity3D基础教程1-4:发布编译(Publishing Builds)

2014-08-05 22:04:20|?次阅读|上传:huigezrx【已有?条评论】发表评论

关键词:游戏, 虚拟现实, Unity3D|来源:唯设编程网

Unity Manual > User Guide > Unity Basics > Publishing Builds

Unity 手册->用户指南->Unity 基础->发布编译

At any time while you are creating your game, you might want to see how it looks when you build and run it outside of the editor as a standalone or web player. This section will explain how to access the Build Settings and how to create different builds of your games.

在任何时候,在你创建你的游戏过程中,你可能希望看到作为独立的或网格播放器外观当你编译并运行它时。本节将说明如何访问生成设置和如何创建你的游戏的不同版本。

File->Build Settings... is the menu item to access the Build Settings window. It pops up an editable list of the scenes that will be included when you build your game.

File->Build Settings...(文件->生成设置是菜单项用于访问生成设置窗口。它弹出一个包含当你创建你的游戏时的场景编辑列表


The Build Settings window 生成设置窗口

The first time you view this window in a project, it will appear blank. If you build your game while this list is blank, only the currently open scene will be included in the build. If you want to quickly build a test player with only one scene file, just build a player with a blank scene list.

 

首先,你在项目面板里看到这个窗口。它将显示空白。如果你创建的你的游戏当它的清单是空白时,仅当前打开的场景将被包含在生成里。如果你想快速的生成一个仅用一个场景文件的测试播放器,只需生成一个使用空白场景清单的播放器。

It is easy to add scene files to the list for multi-scene builds. There are two ways to add them. The first way is to click the Add Current button. You will see the currently open scene appear in the list. The second way to add scene files is to drag them from the Project View to the list.

很容易的添加场景文件到多场景生成的清单里。有两种方法去添加它们。第一种方法是点击Add Current(添加当前)按钮。你将看到当前打开的场景显示在清单里。第二种添加场景文件的方法是从项目面板拖动它们到这个清单。

At this point, notice that each of your scenes has a different index value. Scene 0 is the first scene that will be loaded when you build the game. When you want to load a new scene, use Application.LoadLevel() inside your scripts.

在这一点上,注意每一个你的场景有一个不同的索引值。场景0是当你生成游戏时将被装入的第一个场景。

当你想装载一个新的场景,在你的脚本内部使用Application.LoadLevel()

If you've added more than one scene file and want to rearrange them, simply click and drag the scenes on the list above or below others until you have them in the desired order.

如果你已经添加了多于一个场景文件并想重新排列它们,仅仅点击和拖动这个场景到上面或低于其它场景直到你希望的顺序。

If you want to remove a scene from the list, click to highlight the scene and press Command-Delete. The scene will disappear from the list and will not be included in the build.

如果你想从清单中移除一个场景,点击去突出显示这个场景并按Command-Delete键(在windows里按Delete键),场景将从清单里消失并不在被包含在生成里

When you are ready to publish your build, select a Build target and press the Build button. You will be able to select a name and location for the game using the standardized Save dialog. When you click Save, Unity builds your game pronto. It's that simple. If you are unsure where to save your built game to, consider saving it into the projects root folder. You cannot save the build into the Assets folder.

当你准备好去发布你的生成,选择一个生成目标并按生成按钮。你将能选择一个名称和使用标准保存对话框的游戏的定位。当你点击保存,Unity快速生成你游戏。就这么简单。如果你不确定你生成的游戏保存在哪里,考虑保存它到项目的根文件夹里。你不能保存生成到资产文件夹里。

Enabling the Compress Textures checkbox will compress all the textures in your project when it is built. You only need to compress a texture once, but the first time you perform the compression it could take a few minutes. When you update assets after compressing them, they will need to be re-compressed the next time you build a player. Alternatively, you can enable texture compression upon import from the Unity->Preferences menu.

启用压缩纹理复选框,当它生成时将压缩项目中的所有纹理。你仅需要压缩一个纹理一次,但第一次你处理压缩可能需要几分钟。当你在压缩它们后更新资产,它们将在下一次你建立一个播放器重新被压缩。或者,你可以在引入之上启用纹理压缩,从菜单 Unity->Preferences (参数设置)(windows里是 Edit->Preferences)

Enabling the Strip Debug Symbols checkbox will remove debugging information from the built player. This will reduce the file size of the published game so it's optmimal for completed games. Alphas or betas should have this option disbled for debugging purposes. Your final release should always have this checkbox enabled.

启用脚本符号调式复选框,将移除调式信息重生成播放器里(File->Build Setting…File->Build &Run菜单设置)。这将减少发布的游戏文件的大小。以便完成游戏的优化。Alphas或 betas应该用于调试目的的disbled选项。你最终发布总应该启用此选项。(注意,在Unity 2.5 for windows版本里没有找到该选项)

Web Player Streaming Web流播放器

Streaming Web Players allow your Web Player games to begin playing as soon as Scene 0 is finished loading. If you have a game with 10 levels, it doesn't make much sense to force the player to wait and download all assets for levels 2-10 before they can start playing level 1. When you publish a Streaming Web Player, the assets that must be downloaded will be sequenced in the order of the Scene file they appear in. As soon as all assets contained in Scene 0 are finished downloading, the Web Player will begin playing.

流式Web 播放器允许你的Web 玩家游戏开始播放尽快完成场景0的装载。如果你有一个10层次的游戏,在他们开始玩第一层次之前强制玩家等待和下载所有的2-10层次的资产没有多大意义。资产必须以它们显示的顺序场景的文件序列化顺序被下载。一旦包含在场景0的所有资产下载完成,Web播放器将开始播放。

Put simply, Streaming Web Players will get players playing your game faster than ever.

简单的说,流式Web播放器将使得播放器播放快速的播放你游戏。

The only thing you need to worry about is checking to make sure that the next level you want to load is finished streaming before you load it.

仅有一件事你需要关心的是,在你装载它之前,检查确保下一个层级你想去装载完成的流。

Normally, in a non-streamed player, you use the following code to load a level:

通常情况下,在一个非流式播放器,你使用如下的代码去装载一个层次:

Application.LoadLevel("levelName");

In a Streaming Web Player, you must first check that the level is finished streaming. This is done through the CanStreamedLevelBeLoaded() function. This is how it works:

在一个流式Web播放器里,你必须检查这个层级是已经完成的流。通过CanStreamedLevelBeLoaded()函数这样做。这是它的工作原理:

var levelToLoad = 1;

function LoadNewLevel () {
    if (Application.CanStreamedLevelBeLoaded (levelToLoad)) {
          Application.LoadLevel (levelToLoad);
     }
}

If you would like to display the level streaming progress to the player, for a loading bar or other representation, you can read the progress by accessing GetStreamProgressForLevel().

如果你想显示层次流的进度在播放器里,如一个装载条或其它表现方法,通过方法GetStreamProgressForLevel()你可以读取进度。

Inside the build process 内部生成过程

The building process will place a blank copy of the built game application wherever you specify. Then it will work through the scene list in the build settings, open them in the editor one at a time, optimize them, and integrate them into the application package. It will also calculate all the assets that are required by the included scenes and store that data in a seperate file within the application package.

生成过程将放置你指定的地方生成游戏程序的一个空白副本。然后,它将通过在生成设置里的场景列表,一次一个的在编辑器里打开它们、优化它们并结合它们到应用程序包里。它也将计算包括场景和存储数据在一个独立文件在应用程序内部包里的需要的所有资产。

*       Any GameObject in a scene that is tagged with 'EditorOnly' will be not be included in the         published build. This is useful for debugging scripts that don't need to be included in the final game.

*       任何被标记为“EditorOnly”的场景里的游戏对象将不被包含在发布生成里。对于调试脚本是非常有用的,在最终游戏里不需要包含。

*       When a new level loads, all the objects in the previous level are destroyed. To prevent this, use DontDestroyOnLoad() on any objects you don't want destroyed. This is most commonly used for keeping music playing while loading a level, or for game controller scripts which keep game state and progress.

*       当一个新的层次装载,在以前层次里的所有游戏对象被销毁。为了避免这种情况,在任何你不想销毁的对象上使用DontDestroyOnLoad()。这最常用于保持音乐播放在装载一个层次时、或为游戏控制脚本保持游戏状态或进展。

*       After the loading of a new level is finished, the message: OnLevelWasLoaded() will be sent to all active game objects.

*       一个新的层次装载完成后,信息:OnLevelWasLoaded() 将被发送到所有活动的游戏对象。

*       For more information on how to best create a game with multiple scenes, for instance a main menu, a high-score screen, and actual game levels, see the Scripting Tutorial.pdf

*       如何最佳建立一个多场景游戏的更多信息,例如:实例化一个主菜单,高分辨率屏幕以及真实的游戏层次,查看脚本教程文件。(文件Tutorial.pdf)

Preloading 预装入

Published builds automatically preload all assets in a scene when the scene loads. The exception to this rule is scene 0. This is because the first scene is usually a splashscreen, which you want to display as quickly as possible.

发布生成自动预装入场景里的所有资产当场景装载时。这个例外的规则是场景0.这是因为第一个场景通常是启动动画,那个你想尽可能的尽快显示。

To make sure all your content is preloaded, you can create an empty scene which calls Application.LoadLevel(1). In the build settings make this empty scene's index 0. All subsequent levels will be preloaded.

为了确保你所有的内容是预装入的,你可以创建一个空的场景,调用Application.LoadLevel(1)在生成设置使这个空的场景的索引为0。所有后来的层次将被预装入。

You're ready to build games 你已准备好去生成游戏

By now, you have learned how to use Unity's interface, how to use assets, how to create scenes, and how to publish your builds. There is nothing stopping you from creating the game of your dreams. You'll certainly learn much more along the way, and we're here to help.

现在,你已经学会了如何使用Unity的界面,如何使用资产,如何建立场景,以及如何发布你的生成。没有什么阻止你建立你的梦幻游戏。你将当然沿着这个路学习更多,我们在这里帮组。

To learn more details about using Unity itself, you can continue reading the manual or follow the Tutorials.

要学习关于使用Unity它自己的更多详细信息,你可以继续阅读本指南后面的手册。

To learn more about Components, the nuts & bolts of game behaviors, please read the Component Reference.

要了解更多组件、游戏行为的更多细节,请阅读组件参考。

To learn more about Scripting, please read the Scripting Reference.

要了解更多关于脚本,请阅读脚本参考。

To learn more about creating Art assets, please read the Assets section of the manual.

要了解更多关于创建资产技巧,请阅读本手册的资产章节。

To interact with the community of Unity users and developers, visit the Unity Forums. You can ask questions, share projects, build a team, anything you want to do. Definitely visit the forums at least once, because we want to see the amazing games that you make.

与Unity用户和开发者团体互动,访问Unity论坛。你可以提出问题,共享醒目、建立团队、你想做的任何事情。至少访问一次论坛,因为我们想看到你制作的惊人游戏。

发表评论0条 】
网友评论(共?条评论)..
Unity3D基础教程1-4:发布编译(Publishing Builds)