Multi-resolution assets using Unity5.0 Assetbundles

Hello,

following this discussion on the Unity forums, I decided to dig around and see how the new assetbundles works. I found a video from Unite2014 about it where they did exactly what was described in that thread about having different assets for different builds. Luckily the person who held the presentation also uploaded the source that he used to demo the new Assetbundle features.

Using the project as a template I was able to create a SD and HD version of a sample sprite. However when Implementing the code to my own project I wasn’t able to do so. The scripts I used are the same as in the assetbundle demo mentioned above. Bellow I have screenshots of my folders and assetbunde labels:

42918-screen-shot-2015-03-19-at-160112.png

As the folder names suggest, they have the label suffix of .hd, sd and ud respectively.

42919-screen-shot-2015-03-19-at-160238.png

Shows the labels.

The scene used in this is an empty scene with a canvas and a panel, the panel uses the BG sprite in its Image component.

Bellow is the loader script I’m using:

public class LoadVariants : BaseLoader {

	public string variantSceneAssetBundle = "xplatform/assetbundletest.unity3d";
	public string variantSceneName = "assetbundletest";
	public string[] activeVariants = {"hd"};

	// Use this for initialization
	IEnumerator Start () {

		yield return StartCoroutine(Initialize() );

		// Set active variants.
		AssetBundleManager.Variants = activeVariants;

		// Load variant level which depends on variants.
		yield return StartCoroutine(LoadLevel (variantSceneAssetBundle, variantSceneName, true) );
		
		// Unload assetBundles.
		AssetBundleManager.UnloadAssetBundle(variantSceneAssetBundle);
	}
}

Which is exactly the same as in the demo, but with the label strings changed. All the other bundle building code, loading code, etc is the same as in the demo.

Did I miss a vital piece of setup ?

Thanks in advance for your time!

Alright Mike, as I have mentioned before, it works when using the demo provided by your colleague from Unite2014. He built the assetbundles the same way I did, in addition he has a couple more elements in the scene, where I have only a sprite.

Then he has a empty scene with a GameObject that has a this loaderscript in it:

public class LoadVariants : BaseLoader {

	public string variantSceneAssetBundle = "variants/variant-scene.unity3d";
	public string variantSceneName = "variant-scene";
	public string[] activeVariants = {"hd"};

	// Use this for initialization
	IEnumerator Start () {

		yield return StartCoroutine(Initialize() );

		// Set active variants.
		AssetBundleManager.Variants = activeVariants;

		// Load variant level which depends on variants.
		yield return StartCoroutine(LoadLevel (variantSceneAssetBundle, variantSceneName, true) );
		
		// Unload assetBundles.
		AssetBundleManager.UnloadAssetBundle(variantSceneAssetBundle);
	}
}

// Set active variants.
AssetBundleManager.Variants = activeVariants;

Sets the variant I would like to use, and in my previous the RemapVariantName func find the closest name to it and uses(loads) it, since they are xplatform/ sprites .sd/ud and hd, they all share the same id and can be read from the manifest. If I understood the video correctly. Wasn’t this essentially the biggest update of the 5.0 assetbundles?

When editing the assetbundles demo by adding the ud version sprites and rebuilding the assets, it works. By changing in the inspector to sd, hd or ud. It changes which assets are to be loaded. However when trying to do the exact same in my project it doesn’t load them. Just to clarify, the demo came with SD and HD examples and I added a UD assets folder and rebuilt the assetsbundle, as can be seen here.

Don’t use it, it’s bad