用户工具

站点工具


侧边栏



Unity3D中文文档

script:unityengine:classes:assetbundle:assetbundle

AssetBundle 资源包

Namespace: UnityEngine

Inherits from: Object

Description 描述

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: WWW.assetBundle, Loading Resources at Runtime, BuildPipeline.BuildAssetBundle.

Variables 变量

mainAsset Main asset that was supplied when building the asset bundle (Read Only).
主资源是在构建资源包时指定(只读)。

Public Functions 公有函数

Contains Check if an AssetBundle contains a specific object.
如果AssetBundle的名称中包含特定的对象则进行检索。
GetAllAssetNamesReturn all asset names in the AssetBundle.
返回所有资源包所有的的资源名字。
GetAllScenePathsReturn all the scene asset paths (paths to *.unity assets) in the AssetBundle.
返回资源包中所有的场景资源路径( *.unity 资源路径)。
LoadAllAssetsLoads all assets contained in the asset bundle that inherit from type.
加载所有包含在资源包中继承自type的对象。
LoadAllAssetsAsyncLoads all assets contained in the asset bundle asynchronously.
异步加载所有资源包中的资源。
LoadAssetLoads asset with name from the bundle.
根据资源名加载资源包中资源。
LoadAssetAsyncAsynchronously loads asset with name from the bundle.
根据资源名异步加载资源包中资源。
LoadAssetWithSubAssetsLoads asset and sub assets with name from the bundle.
根据资源名加载和替换资源包中资源。
LoadAssetWithSubAssetsAsyncLoads asset with sub assets with name from the bundle asynchronously.
根据资源名异步加载和替换资源包中资源。
Unload Unloads all assets in the bundle.
卸载所有包含在bundle中的对象。

Static Functions 静态函数

LoadFromFile 同步从硬盘加载资源包
LoadFromFileAsync 异步从硬盘加载资源包
LoadFromMemory同步从内存创建资源
LoadFromMemoryAsync异步从内存创建资源

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 = new WWW ("http://myserver/myBundle.unity3d");
		yield return www;
		// Get the designated main asset and instantiate it.
		Instantiate(www.assetBundle.mainAsset);
	}
}
script/unityengine/classes/assetbundle/assetbundle.txt · 最后更改: 2016/11/17 09:14 由 xokms