Namespace: UnityEngine
Inherits from: Object
AssetBundles let you stream additional assets via the WWW class and instantiate them at runtime. AssetBundles are created via BuildPipeline.BuildAssetBundle.
AssetBundles让你通过WWW类流加载资源并在运行时实例化它们。AssetBundles通过BuildPipeline.BuildAssetBundle创建。
Note that bundles are not fully compatible between platforms. A bundle built for any of the standalone platforms (including webplayer) can be loaded on any of those platforms but not on iOS or Android. Furthermore, a bundle built for iOS is not compatible with Android and vice versa.
注意,资源包在平台间不完全兼容。资源包编译为standalone平台(包含webplayer)可以被任意平台加载,但不包括iOS和Android平台。此外,资源包编译为iOS是不兼容Android,反之亦然。
See Also: .
JavaScript:
function Start () { var www = WWW ("http://myserver/myBundle.unity3d"); yield www; // Get the designated main asset and instantiate it. Instantiate(www.assetBundle.mainAsset); }
C#:
using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { IEnumerator getAsset () { WWW www = WWW ("http://myserver/myBundle.unity3d"); yield return www; // Get the designated main asset and instantiate it. Instantiate(www.assetBundle.mainAsset); } }
mainAsset | Main asset that was supplied when building the asset bundle (Read Only). 主资源是在构建资源包时指定(只读)。 |
Contains | Check if an AssetBundle contains a specific object. 如果AssetBundle的名称中包含特定的对象则进行检索。 |
GetAllAssetNames | Return all asset names in the AssetBundle. 返回所有资源包所有的的资源名字。 |
GetAllScenePaths | Return all the scene asset paths (paths to *.unity assets) in the AssetBundle. 返回资源包中所有的场景资源路径( *.unity 资源路径)。 |
LoadAllAssets | Loads all assets contained in the asset bundle that inherit from type. 加载所有包含在资源包中继承自type的对象。 |
LoadAllAssetsAsync | Loads all assets contained in the asset bundle asynchronously. 异步加载所有资源包中的资源。 |
LoadAsset | Loads asset with name from the bundle. 根据资源名加载资源包中资源。 |
LoadAssetAsync | Asynchronously loads asset with name from the bundle. 根据资源名异步加载资源包中资源。 |
LoadAssetWithSubAssets | Loads asset and sub assets with name from the bundle. 根据资源名加载和替换资源包中资源。 |
LoadAssetWithSubAssetsAsync | Loads asset with sub assets with name from the bundle asynchronously. 根据资源名异步加载和替换资源包中资源。 |
Unload | Unloads all assets in the bundle. 卸载所有包含在bundle中的对象。 |
CreateFromFile | Loads an asset bundle from a disk. 从硬盘来加载资源包。 |
CreateFromMemory | Asynchronously create an AssetBundle from a memory region. 从内存区异步创建资源包。 |
CreateFromMemoryImmediate | Synchronously create an AssetBundle from a memory region. 从内存区同步创建资源包。 |