- Home /
Question by
_developer_ · Oct 29, 2014 at 02:23 PM ·
assetbundle
[SOLVED] www.assetBundle is null (Unity3d 4.5.5)
Hi! I have a problem with loading asset bundle from file.
I build bundle:
BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, BuildTarget.iPhone)
I download bundle file and save:
WWW www = new WWW (bundleURL);
yield return www;
System.IO.File.WriteAllBytes(Application.persistentDataPath + "/AssetBundle.unity3d", www.bytes);
I load bundle:
WWW www = new WWW("file:///" + Aplication.persistentDataPath + "/AssetBundle.unity3d");
yield return www;
if(www.error != null)
Debug.Log("ERROR: " + www.error);
else
Debug.Log("BUNDLE: " + www.assetBundle);
Always i have debug "BUNDLE: null".
I don't have this problem in editor, but have on device.
What am I doing wrong?
SOLUTION!
Problem was in loading from straming assets. When i loading bundle from Application.streamingAssetsPath need add to url "file:///"
WWW www = new WWW("file:///" + Aplication.streamingAssetsPath + "/AssetBundle.unity3d");
Comment
$$anonymous$$aybe problem in strea$$anonymous$$g assets? I put my bundle on strea$$anonymous$$g assets folder. When i download this file for save i have this problem too.
string bundleURL= Application.strea$$anonymous$$gAssetsPath + "/AssetBundle.unity3d";
WWW www = new WWW (bundleURL);
yield return www;
Debug.Log("BUNDLE: " + www.assetBundle);
System.IO.File.WriteAllBytes(Application.persistentDataPath + "/AssetBundle.unity3d", www.bytes);
I have debug "BUNDLE: null".