var gui : GUITexture;
var find : GameObject;
var GameObjectName;
function Awake(){
//找到guiTexture,当初始加载时让其不可用
find=GameObject.Find("guiTexture");
find.active=false;
GameObjectName=GameObject.Find("Cube").tag;//通过tag来传递参数给www()函数
}
function OnMouseDown(){
find.active=true;
//Debug.Log(GameObjectName);
var SenceName=GameObjectName;
www(SenceName);
}
function www(Cubename){
// Store the original pixel inset
// and modify it from there.
var originalPixelRect = gui.pixelInset;
// Update the progress bar by scaling the gui texture
// until we reach the end
// var stream=new WWW("http://unity3d.com/gallery/hosted-demos/dressingroom.unity3d");本地连接官网上的例子
var stream=new WWW(""+Cubename+".unity3d");//CubeName为你将要下载的场景名字
while (!stream.isDone)
{
gui.pixelInset.xMax = originalPixelRect.xMin+ stream.progress * originalPixelRect.width;
yield;
}
// Update it one last time before loading
gui.pixelInset.xMax = originalPixelRect.xMax;
stream.LoadUnityWeb();
}
@script RequireComponent (GUITexture)