Hello,
I’ve a issue on running my game on iOS device that doesn’t occur in editor. I’ve encounter this problem since I update to Unity 4.3.3 (I was on Unity 4.3.0 before or 4.3.1, I’m not sure about it).
I used asset bundles that are downloaded with WWW object.
Here is my sample of code downloading the bundle (wich contains a scene).
IEnumerator StartDownloadScene(string url)
{
WWW download = new WWW(url);
yield return download;
if (!string.IsNullOrEmpty(download.error))
{
Application.LoadLevel("NotAvailable");
}
while (download.isDone == false)
{
yield return null;
}
if(download.assetBundle == null)
{
Debug.LogError(url+" has no asset bundle");
}
Debug.LogError("progress : +"download.progress);
}
When I execute my game from Unity Editor (on Mac OS X), no problem : my asset bundle is loaded, without error and the value of download.assetBundle is not nulland progress is 100% .
However, when I execute the game on iPad from XCode, download.assetBundle is null and progress is 0% (only 13 KB downloaded on 3.4MB).
But it is exactly the same file I download, and I packed the asset bundle with iOS as target plateform.
Here is the code I use to do that (in a script editor) :
static void BuildAssetBundle(BuildTarget target)
{
string assetPath = AssetDatabase.GetAssetPath(Selection.activeObject);
//make sure user has a scene selected:
if (Selection.objects.Length != 1 || !assetPath.Contains(".unity"))
{
EditorUtility.DisplayDialog("Scene Asset Bundle Creation", "Please select a single scene in your project.", "OK");
return;
}
//set a save location for the bundle:
string savePath = EditorUtility.SaveFilePanel("Save Scene Asset Bundle for "+ target.ToString(), "", "Scene_"+target.ToString(), "unity3d");
if (savePath == "")
{
return;
}
//save asset bundles for iphone and android:
string[] pathPieces = savePath.Split('.');
BuildPipeline.BuildStreamedSceneAssetBundle(new string[] { assetPath }, savePath, target);
//complete:
EditorApplication.Beep();
EditorUtility.DisplayDialog("Scene Asset Bundle Creation" , "Scene asset bundle built for " + target.ToString(), "OK");
}
And here is the call of this function :
BuildAssetBundle(BuildTarget.iPhone);
I tried to rebuild asset bundle with Unity 4.3.3 but it doesn’t solve the probleme.
All of this was good in november the last time I work on my game.
The file exists, the download.isDone valuye is true, but progress is 0 ans assetBundle is null. I don’t understand what I miss.
I try on two different iPad (iPad 4 and iPad 2) with the same issue.
Is there new features for Asset Bundle that I have missed ? Something in creating or downloading asset Bundle I did wrong ?
Thank you for your answers !
–
UPDATE : Solved with Unity 4.3.4