WWW.LoadUnityWeb 加载UnityWeb文件

function LoadUnityWeb () : void

Description描述

Loads the new web player data file.

加载新的web播放器数据文件。

The first level of the loaded .unity3d file will automatically be loaded. All objects, scripts and static variables from the previous .unity3d file will be unloaded. You can move information between the two sessions using PlayerPrefs class.

加载的unity3d文件的第一个关卡将自动被加载,所有来自前一个.unity3d文件的物体、脚本和静态变量将被卸载。你可以使用PlayerPrefab类在两个绘画间移动信息。

This function is only supported in the web player.

这个函数只能在web播放器中使用。

If the object has not finished downloading the unity3d file will not be loaded. Use isDone or yield to see if the data is available.

如果对象尚未完成下载,unity3d文件将不会被加载。使用isDone或yield查看数据是否可用。

function Start () {
	// Start streaming the data file
	//开始流数据文件
	var stream = new WWW ("http://www.unity3d.com/webplayers/Lightning/lightning.unity3d");
	// Yield until stream is done
	//等待流完成
	yield stream;
	// Load it!
	//加载
	stream.LoadUnityWeb();
}

又一个例子:

// Streams a .unity3d file and displays the progress in a GUI texture.
// You need to make sure the GUI texture is set up to have a pixel inset.
// 下载一个.unity3d文件并在GUI纹理中显示进度,你需要确保GUI纹理被设置为具有一个pixelInset
function Start () {
	// Store the original pixel inset and modify it from there.
	// 保存原始的pixelInset并修改它
	var originalPixelRect = guiTexture.pixelInset;

	// Update the progress bar by scaling the gui texture until we reach the end
	// 通过缩放GUI纹理来更新进度条,直到到达末尾
	var stream = new WWW ("http://www.unity3d.com/webplayers/Lightning/lightning.unity3d");
	while (!stream.isDone) {
		guiTexture.pixelInset.xMax = originalPixelRect.xMin + stream.progress * originalPixelRect.width;

		yield;
	}
	// Update it one last time before loading
	// 在加载之前更新最后一次
	guiTexture.pixelInset.xMax = originalPixelRect.xMax;

	stream.LoadUnityWeb();
}
Page last updated: 2011-4-25