Quantcast
Channel: Questions in topic: "assetbundle"
Viewing all articles
Browse latest Browse all 1593

Problem with AssetBundle unloading and mainAsset

$
0
0
Hi! I have a problem with AssetBundle. When using WWW to load an AssetBundle and get a object from AssetBundle.mainAsset, are there any side effects to call function AssetBundle.Unload(false) to free memory? It seems like that if function Unload(false) is called, the object won't be destroyed when the function AssetBundle.Unload(true) is called. ps. The mainAsset is a Texture2D in my test case. Example code: public class TestUnload : MonoBehaviour { void Start () { StartCoroutine(TestLoad()); } IEnumerator TestLoad() { string BundleURL = "file://" + Application.streamingAssetsPath + "/texture.assetbundle"; using (WWW www = new WWW(BundleURL)) { yield return www; m_testObject = www.assetBundle.mainAsset; www.assetBundle.Unload(false); // wait 2 seconds for test yield return new WaitForSeconds(2.0f); www.assetBundle.Unload(true); } if (m_testObject != null) { Debug.Log("m_testObject != null"); } else { Debug.Log("m_testObject == null"); } } Object m_testObject = null; } if www.assetBundle.Unload(false) is called --> m_testObject != null if www.assetBundle.Unload(false) is not called --> m_testObject == null Thanks

Viewing all articles
Browse latest Browse all 1593

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>