一.
1.關於如何打包成ab包,就不多說了,網上很多教程,siki學院也有siki老師的免費視頻教程挺詳細的,可以看看 http://www.sikiedu.com/my/course/74
2.為了圖方便,用了siki老師說的AssetBundlesBrowser打包工具,這個工具還可以查看包內容,滿贊的
二.打包完成之后得到ab包
1.直接上代碼吧,畢竟那么簡單
IEnumerator wait() { string path = Application.streamingAssetsPath + "/test.ab";//ab包位置//test.ab是我ab包的名字 WWW www = new WWW(path); yield return www; if (string.IsNullOrEmpty(www.error)) { //獲取到ab包資源 AssetBundle bundle = www.assetBundle; //輸出所有資源地址 string[] strs = bundle.GetAllScenePaths(); foreach (string str in strs) Debug.Log(str); //一步讀取場景 AsyncOperation async = SceneManager.LoadSceneAsync("Test");//不需要帶后綴//這里Test是我的場景名字 async.allowSceneActivation = false; while (async.progress < 0.9f) { Debug.Log("場景進度 " + async.progress); yield return null; } async.allowSceneActivation = true; yield break; } Debug.Log("讀取錯誤 " + www.error); }