2014-08-16 12:22:43|?次阅读|上传:huigezrx【已有?条评论】发表评论
关键词:Unity3D, 游戏, 虚拟现实|来源:唯设编程网
Unity Manual > Advanced > Loading Resources at Runtime
Unity手册->高级->在运行时装入资源
There are a number of scenarios where you want to include some kind of asset in your finished game that is not included inside the primary game executable; standalone or web player. One scenario is to slim a webplayer download size, and dynamically download and instantiate individual objects or items. This way only the relevant and needed objects are used by the end-user. Another scenario might be for downloadable content like additional weapons, environments, characters, or even full levels.
有多种方案可以实现在你完成的游戏里的包含多种类型的资产但不包含于可执行基本游戏内部:独立或网络播放器。一种情况是小的webplayer下载尺寸,以及动态下载和实例化对象的项目或它自己。这只是相关的和需要的对象被最终用户使用。另一种方案可能会像其他的武器,环境,人物,甚至完全级别下载内容。
In Unity Pro, you can choose between two options for accomplishing these tasks: Asset Bundles, and Resource Folders. Unity Indie license holders can use Resource Folders only.
在Unity的专业版本里,你可以选择两个选项为完成这些任务:资产包,和资源文件夹。Unity独立的许可以仅能使用的资源文件夹。
An Asset Bundle is an external collection of assets. You can have many Asset Bundles and therefore many different external collections of assets. These files exist outside of the built Unity player, usually sitting on a web server for end-users to access dynamically.
一个资产包是资产的外部集合。你可以有很多资产包,因此许多不同资产的外部集合。这些文件存在创建的Unity的 播放器的外面,通常是位于一个Web服务器上为用户访问动态。
To build an Asset Bundle, you call BuildPipeline.BuildAssetBundle() from inside a script. In the arguments, you specify an array of Objects to be included in the built file, along with some other options. This will build a file that you can later load dynamically in the runtime by using AssetBundle.Load().
建立一个资产包,你调用BuildPipeline.BuildAssetBundle()从内部一个脚本里。在变量里,你指定一个对象数组包被含在建立的文件里,以及一些其他的选择。这将建立一个文件,你以后可以在运行时动态加载使用AssetBundle.Load()。
Resource Folders are collections of assets that are included in the built Unity player, but are not necessarily linked to any GameObject in the Inspector.
资源文件夹是资产的集合,包括,在Unity里所建立的播放器,但不必连接到任何在检视器里的GameObject。
To put anything into a Resource Folder, you simply create a new folder inside the Project View, and name the folder "Resources". You can have multiple Resource Folders organized differently in your Project. Whenever you want to load an asset from one of these folders, you call Resources.Load().
放任何东西到一个资源文件夹里,你只需在项目视图里创建一个的新文件夹,并命名文件夹为“资源”。你可以有多个资源文件夹组织不同的资源在你的项目里。每当你要加载的其中一个文件夹的资产,你调用Resources.Load()。
If your target deployable is a Streaming Web Player, you can define which scene will include everything in your Resource Folders. You do this in the Player Settings, accessible via Edit->Project Settings->Player. Set the First Streamed Level With Resources parameter, and all assets in your Resource Folders will be loaded when this level streams in to the end-user.
如果你的目标是部署一个流Web播放器,你可以定义场景将包含在你资源文件夹里的一切。你在播放机设置做到这一点,通过访问Edit->Project Settings->Player。设置第一流级使用资源参数,并且在你的资源文件夹的所有资产将被最终用户装载在这一水平流。