My code is following:
@script ExecuteInEditMode()
var guiXOffset = 0;
var url = "";
var download : WWW;
private var isLoading = false;
function Download(){
isLoading = true;
yield download;
if(download.assetBundle != null || download.assetBundle.mainAsset != null){//download successed
//instantiate main asset
var o = Instantiate(download.assetBundle.mainAsset);
if(o!=null){
o.transform.position = new Vector3(0,0,0);
}
}else{
Debug.Log("Can not download resource!!!");
}
}
function OnGUI () {
if(download == null){
if(GUI.Button(Rect(0,160,200,20),"Download "+url)){
//check the runtime eviromnment
if (Application.platform == RuntimePlatform.OSXWebPlayer || Application.platform == RuntimePlatform.WindowsWebPlayer){
download = new WWW (url);
}
else if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.WindowsEditor){
download = new WWW ("file://" + Application.dataPath + "/../" + url);
}
Download();
}
}
//show process
if(isLoading){
GUI.Button(Rect(0,160,200,20),(download.progress*100)+"%");
}
}
I want to show the button in edit mode, but it doesn’t work,why? My license is Unity Pro 30 days’ Trail.