- Home /
UnloadAsset can only be used on assets
i want to read one texture with sequence, my code is below: ///
/// Dispaly image with a sequence loop. /// /// IEnumerator DisplayImage() { int count = imagepaths.Length;
while (n < count)
{
WWW imagetemp = new WWW("file://D:/Ebook/" + imagepaths[n]);
yield return imagetemp;
Texture tex = _image.renderer.material.mainTexture;
_image.renderer.material.mainTexture = imagetemp.texture;
n++;
Resources.UnloadAsset(tex);
yield return new WaitForSeconds(1f);
}
}
when display the third image, i receive an error : UnloadAsset can only be used on assets ? what can i do ?
Answer by GameVortex · Jan 06, 2015 at 08:23 AM
Resources.UnloadAsset only works on assets in your UnityProject. When loading textures through the WWW class, you can unload them again by calling Destroy on the texture.
Example:
Destroy(tex);
do you mean that i create a assetbundle ,then load a asset tex1 ,and i can use the resource.unloadasset to unload the asset tex1 ?
No, assetbundles are not assets in your project. They are loaded externally on runtime. To unload an entire assetbundle you use: AssetBundle.Unload. But to sort of unload specific assetbundle assets you use Destroy on the asset.
Your answer
Follow this Question
Related Questions
Critical problem in importing scripts 3 Answers
2D Array Rigidbody details storing error - C# 1 Answer
really weird error - parameter must be of type: 2 Answers
Why is Unity built in recorder not working? 0 Answers
2D bullet script errors. 1 Answer