返回介绍

AssetBundle 资源包

发布于 2019-12-18 15:37:20 字数 4959 浏览 977 评论 0 收藏 0

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.

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);
	}
}

Variables 变量

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

Public Functions 公有函数

ContainsCheck 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.
根据资源名异步加载和替换资源包中资源。
UnloadUnloads all assets in the bundle.
卸载所有包含在bundle中的对象。

Static Functions 静态函数

CreateFromFileLoads an asset bundle from a disk.
从硬盘来加载资源包。
CreateFromMemoryAsynchronously create an AssetBundle from a memory region.
从内存区异步创建资源包。
CreateFromMemoryImmediateSynchronously create an AssetBundle from a memory region.
从内存区同步创建资源包。

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文