I tried modifying the code to the following:
IEnumerator StartLoadingLevel()
{
Debug.Log("starting download");
var download = WWW.LoadFromCacheOrDownload(adventureLocation,5);
yield return download;
if (download.error != null)
{
Debug.Log(download.error);
}
Debug.Log("successful download");
var bundle = download.assetBundle;
yield return bundle;
string tempName = adventureLocation;
tempName = tempName.Substring(tempName.LastIndexOf('/') + 1);
Debug.Log("building");
BuildPipeline.BuildStreamedSceneAssetBundle(tempName, "Assets/" + tempName,BuildTarget.Android);
Debug.Log("starting level");
Application.LoadLevel(tempName);
}
But I got the following error messages:
Assets/Scripts/menu.cs(67,31): error CS1502: The best overloaded method match for `UnityEditor.BuildPipeline.BuildStreamedSceneAssetBundle(string[], string, UnityEditor.BuildTarget)' has some invalid arguments
Assets/Scripts/menu.cs(67,31): error CS1503: Argument `#1' cannot convert `string' expression to type `string[]'
I then tried the following code:
IEnumerator StartLoadingLevel()
{
Debug.Log("starting download");
var download = WWW.LoadFromCacheOrDownload(adventureLocation,5);
yield return download;
if (download.error != null)
{
Debug.Log(download.error);
}
Debug.Log("successful download");
var bundle = download.assetBundle;
yield return bundle;
string tempName = adventureLocation;
tempName = tempName.Substring(tempName.LastIndexOf('/') + 1);
Debug.Log("building");
var levels : String[] = ["Assets/" + tempName];
BuildPipeline.BuildStreamedSceneAssetBundle(levels, "Assets/" + tempName,BuildTarget.Android);
Debug.Log("starting level");
Application.LoadLevel(tempName);
}
But I got the following error in the editor without being able to press the play button:
Assets/Scripts/menu.cs(67,28): error CS1525: Unexpected symbol `:', expecting `)', `,', `;', `[', or `='
I go the last example from: http://docs.unity3d.com/Documentation/ScriptReference/BuildPipeline.BuildStreamedSceneAssetBundle.html
Jason
↧