- Home /
downloaded texture AssetBundle
I builded my assetbundles but those are only textures. How can those downloaded assetbundles be available to its specified gameobject? Does it automatically LINK to its specified gameobjects?
I've tried my question but it seems it is not working or I just dont know how to do it.
IEnumerator DownloadAndCache (){
while (!Caching.ready)
yield return null;
using(WWW www = WWW.LoadFromCacheOrDownload (BundleURL, version))
{
yield return www;
if (www.error != null)
throw new Exception("WWW download had an error:" + www.error);
AssetBundle bundle = www.assetBundle;
}
}
If you are just downloading textures, I would not bother the AssetBundle, just downloading texture via url. Just my thought.
For your issue, the texture is not linked to any assets within the running project. You need to deserialize the texture from the bundle, then get the reference to the GameObject that should be using the texture and assign it to the material.
Answer by iMagesBlues · Oct 21, 2016 at 12:16 PM
Unless you are bundling a gameobject with texture references as a prefab, I think you will have to load each texture manually. You can try:
Texture2D texture1 = bundle.LoadAsset("texture1", typeof(Texture2D))
Texture2D texture2 = bundle.LoadAsset("texture2", typeof(Texture2D))
etc..
or
Texture2D[] textures = bundle.LoadAllAssets(typeof(Texture2D))
You can also refer to Unity docs for reference. :) https://docs.unity3d.com/ScriptReference/AssetBundle.html
Your answer
![](https://koobas.hobune.stream/wayback/20220612095109im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to create an assetbundle of an image folders and then load these images as texture? 0 Answers
Can assetbundles have .asset files in them?? 0 Answers
How to build only specified assets into assetbundle in unity 0 Answers
Material texture properties disappear in asset bundle 0 Answers
Unity 5 Asset Bundles limitations for mobile platforms. 0 Answers