0
我正在試驗Unity3d AssetBundles。我試圖用它的對象加載一個場景。我有我的創造資產包這個簡單的代碼:Unity3d加載assetsbundle
[MenuItem ("Build/BuildAssetBundle")]
static void myBuild(){
string[] levels = {"Assets/main.unity"};
BuildPipeline.BuildStreamedSceneAssetBundle(levels,"Streamed-Level1.unity3d",BuildTarget.Android);
}
我用上面的代碼從在有攝像頭,並在中心的立方體的場景搭建的資產包。
,我有這樣的代碼來加載它:
using UnityEngine;
using System.Collections;
public class loader : MonoBehaviour {
public GUIText debugger;
private string url = "http://www.myurl.com/Streamed-Level1.unity3d";
// Use this for initialization
IEnumerator Start() {
Debug.Log("starting");
WWW www = WWW.LoadFromCacheOrDownload(url,1);
if(www.error != null)
{
Debug.LogError(www.error);
}
yield return www;
Debug.Log("after yield");
AssetBundle bundle = www.assetBundle;
bundle.LoadAll();
Debug.Log("loaded all");
Application.LoadLevel("main");
}
// Update is called once per frame
void Update() {
}
}
的問題是似乎是當它到達去LOADALL停止。
如果有人能幫助我,我將不勝感激。
非常感謝
你的問題幾乎是我的答案,但問題是「Streamed-Level1.unity3d」將保存在哪裏? – 2015-10-30 14:39:32
你有回答這個任務嗎? http://stackoverflow.com/questions/33434835/creating-and-downloading-asset-bundle-from-local-server-in-unity-5 – 2015-10-30 14:42:49