Thanks for reading my post. I have never worked with assetbundles before (never had pro before) and have inherited another programmers project which I need to get using assetbundles again. They worked at some point so I have code, but it does not seem to work now. Did something change between 3-4 with how these have to be called?
Ive spent the last two days reading the forums and trying to get this working… Here is what I have so far. I create the scene assetbundle like this:
[MenuItem("Assets/Build LEVELNAME")]
static void ExportResourceStreamedScene21 ()
{
System.IO.Directory.CreateDirectory ("AssetBundles");
string[] levels = new string[1] {"Assets/Scenes/ExternalScenes/LEVELNAME.unity"};
string[] lvlNames = new string[1] {"Streamed_LEVELNAME.unity3d"};
// Build streamed scene file into a seperate unity3d file
for (int i = 0; i < levels.Length; i++) {
string[] lvl = new string[1] {levels [i]};
BuildPipeline.PushAssetDependencies ();
BuildPipeline.BuildStreamedSceneAssetBundle (lvl, lvlNames [i], BuildTarget.WebPlayer);
BuildPipeline.PopAssetDependencies ();
}
}
I get an assetbundle just fine (whether or not it is in the right format is another question… I try to load the assetbundle like this:
{
DebugToLogs.Add ("1");
if (scenePath.IndexOf ("file://") == 0 || scenePath.IndexOf ("http://") == 0)
download = WWW.LoadFromCacheOrDownload (scenePath, Settings.manager.GetVersionForScene (levelName));
if (Application.platform == RuntimePlatform.OSXWebPlayer || Application.platform == RuntimePlatform.WindowsWebPlayer)
download = new WWW ("../AssetBundles/" + scenePath);
else if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.WindowsEditor)
download = new WWW ("file://" + Application.dataPath + "/../AssetBundles/" + scenePath);
DebugToLogs.Add ("2");
yield return download;
if (download.error != null)
DebugToLogs.Add ("WWW download had an error:" + download.error);
DebugToLogs.Add ("4");
AssetBundle assetBundle = download.assetBundle;
if (assetBundle != null) {
DebugToLogs.Add ("5");
downloadedScenes.Add (assetBundle);
DebugToLogs.Add("" + levelName);
downloadedSceneNames.Add (levelName);
buildSceneList(levelName);
}
}
I never get the debug of “4” and long story short I know the issue is when I am yielding for the download. But every time it freezes and I get the “report a bug” screen when the code is run. I’m assuming the error is definitely on my end and not a bug due to my inexperience with assetbundles.
Anyone have any suggestions or a direction to go in? I am very lost in this and running out of time