Author Topic: NGUI Atlases not destroying.  (Read 1615 times)

dipu5683

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 27
    • View Profile
NGUI Atlases not destroying.
« on: June 17, 2014, 06:13:12 AM »
Hi

I have created two prefab say page1 & page2 . page1 uses atlas1 & page2 uses atlas2 .

Pag1 prefab is the child of UIRoot ( present in the scene from the start ) , And "mainmenu.cs" is attached to it.
following code has bee wrtten to load the page2.

method 1
GameObject ob = (GameObject)Instantiate((GameObject)Resources.Load("page2"));
ob.transform.parent = root.transform;
ob.transform.localScale = new Vector3(1f, 1f, 1f);

method 2
NGUITools.AddChild(root.gameObject, page2);

and to destroy the page1 prefab

DestroyImmediate(this.gameObject, true);
yield return Resources.UnloadUnusedAssets();

(simple example to load & unload the page & atlases)

But in the profiler it still displaying that both atlases in the memory. Even after using the DestroyImmediate for page1 object
it's atlas is still in the memory.

Iam using NGUI 3.5.5.

Can any body help?



« Last Edit: June 17, 2014, 06:23:10 AM by dipu5683 »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI Atlases not destroying.
« Reply #1 on: June 17, 2014, 01:46:58 PM »
Don't use Instantiate. Use NGUITools.AddChild(parent, prefab).

Your NGUI is several months out of date. Please update to the latest. Also before calling UnloadUnusedAssets, call UIDrawCall.ReleaseInactive().