AssetBundles: Including an array of Texture2Ds to iterate across a material.

alt text

So, I have this array of Tex2Ds, and I am iterating over them in a script. I’m using a nice simple…

if (counter >= EndFrame) counter = 0;

			RenderPlane.renderer.material.mainTexture = sortedImages[counter];
			counter++;
		}

… method sat in a coroutine. It works beautifully in editor and when included in a build, but not so well in an assetBundle. It simply wont iterate through those textures, almost as if it isn’t including them.

Our assetBundle exporter has “BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets);” to include dependencies, but I must be missing one more golden step?

(Note: The eagle eyed amongst you may have noticed my frames aren’t in order, these get sorted at runtime).

Edit: It appears that the assetBundle IS including all textures, there is an issue with my code not iterating.

private IEnumerator ImageSequencerCoroutine() {
		while (true) {
			yield return incrementInterval; // type WaitForSeconds

			if (counter >= EndFrame) counter = 0;

			RenderPlane.renderer.material.mainTexture = sortedImages[counter];
			counter++;
		}
			//Assign frame
	}

Fixed, you cannot include runtime scripts in AssetBundles, you will need a script that looks for a tag in your asset bundle that sits in your scene waiting, does a check when the AssetBundle download is finished (I’m firing off an event), then does what it needs to do (or use a static class, whatever you want).