BuildPipeline.PushAssetDependencies 压入资源依赖

static function PushAssetDependencies () : void

Description描述

Lets you manage cross-references and dependencies between different asset bundles and player builds.

让你管理交叉引用和不同资源包和播放器构建之间的依赖关系。

If a asset bundle has dependencies to other asset bundles, it is your responsibility to make sure the dependent asset bundles are loaded through the WWW class.

如果一个资源包与另外的资源包存在依赖关系,  你必须确定依赖的资源包通过WWW类加载。

When you push asset dependencies it will share all resources on that layer, pushing recursively always inherits the previous dependencies. PushAssetDependencies and PopAssetDependencies must even each other out.

当你使资源具有依赖属性, 它将在层上共享所有资源, 推入递归总是继承以前的依赖性关系。 PushAssetDependencies 和PopAssetDependencies 必须相互依赖。

@MenuItem("Assets/Auto Build Asset Bundles")
static function ExportResource () {

	// Enable cross-references for all following asset bundles files until
	// we call PopAssetDependencies
	//启用交叉引用,用于所有跟随的资源包文件,直到我们调用PopAssetDependencies
	BuildPipeline.PushAssetDependencies();

	var options =
		BuildAssetBundleOptions.CollectDependencies |
		BuildAssetBundleOptions.CompleteAssets;

	// All subsequent resources share assets in this asset bundles
	// It is up to you to ensure that the shared asset bundle is
	// loaded prior to loading other resources
	//所有后续资源将共享这一资源包中的内容,由你来确保共享的资源包是否在其他资源载入之前载入
	BuildPipeline.BuildAssetBundle(
		AssetDatabase.LoadMainAssetAtPath("assets/artwork/lerpzuv.tif"),
		null, "Shared.unity3d", options);

	// By pushing and popping around the asset bundle, this file
	// will share resources but later asset bundles will not share assets in this resource
	//通过推入和弹出资源包,这个文件将共享这些资源,但是后续的资源包将无法继续共享它
	BuildPipeline.PushAssetDependencies();
	BuildPipeline.BuildAssetBundle(
		AssetDatabase.LoadMainAssetAtPath("Assets/Artwork/Lerpz.fbx"),
		null, "Lerpz.unity3d", options);
	BuildPipeline.PopAssetDependencies();

	// By pushing and popping around the asset bundle, this file
	// will share resources but later asset bundles will not share assets in this resource
	//通过推入和弹出资源包,这个文件将共享这些资源,但是后续的资源包将无法继续共享它
	BuildPipeline.PushAssetDependencies();
	BuildPipeline.BuildAssetBundle(
		AssetDatabase.LoadMainAssetAtPath("Assets/Artwork/explosive guitex.prefab"),
		null, "explosive.unity3d", options);
	BuildPipeline.PopAssetDependencies();

	// By pushing and popping around the asset bundle, this file
	// will share resources but later asset bundles will not share assets in this resource
	//通过推入和弹出资源包,这个文件将共享这些资源,但是后续的资源包将无法继续共享它
	BuildPipeline.PushAssetDependencies();
	BuildPipeline.BuildPlayer(
		["Assets/AdditiveScene.unity"], "AdditiveScene.unity3d",
		BuildTarget.WebPlayer, BuildOptions.BuildAdditionalStreamedScenes);
	BuildPipeline.PopAssetDependencies();

	BuildPipeline.PopAssetDependencies();
}

参见: PopAssetDependencies, BuildAssetBundle.

最后修改:2011年5月8日 Sunday 9:46

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。