Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: hjbo on January 02, 2014, 03:10:11 AM

Title: UITexture.mainTexture cannot unload resources?
Post by: hjbo on January 02, 2014, 03:10:11 AM
code:
      Texture texture = uiTexture .mainTexture;
      mainBGUITexture.mainTexture = Resources.Load(path + "/" + curFrame, typeof(Texture)) as Texture;
      Resources .UnloadAsset (texture);
this code run in Update Function,Resources .UnloadAsset (texture) does not work,but it work well on NGUI 2.6
I did not carefully read UITexture code,but add two lines of code:uiTexture.enable= false;uiTexture.enable= true;
it can UnloadAsset ,why?  Thanks
Title: Re: UITexture.mainTexture cannot unload resources?
Post by: ArenMook on January 02, 2014, 11:37:44 AM
NGUI panels create draw calls. Draw calls reference textures. When you set some UITexture's mainTexture reference, the change won't result in the draw calls being destroyed right away. The call will be delayed.

You need to delay your UnloadAsset call until the end of frame (yield new WaitForEndOfFrame()).
Title: Re: UITexture.mainTexture cannot unload resources?
Post by: hjbo on January 02, 2014, 11:38:57 PM
Thank you very much