2014-08-16 12:22:43|?次阅读|上传:huigezrx【已有?条评论】发表评论

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

Unity Manual > Advanced > Loading Resources at Runtime


Loading Resources at Runtime 在运行时装入资源

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.


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.


Asset Bundles (Unity Pro-only) 资产包(Uniyt 仅专业版具有)

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().


Resource Folders (Indie and Pro) 资源文件夹(独立版本和专业版本)

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.


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().


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。设置第一流级使用资源参数,并且在你的资源文件夹的所有资产将被最终用户装载在这一水平流。

发表评论0条 】