Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - chad

Pages: [1]
1
Nevermind. It was actually working, however, my initialize function was being called again after the OnApplicationQuit call. I still don't know why, but I have fixed that problem.

2
I am having a similar problem, I am creating a bunch of buttons at runtime in a grid, but the buttons are not being destroyed afterwards.

Here is how I add the buttons:

  1. GameObject grid = GameObject.Find("Logic Grid");
  2.  
  3. int length = PlayEditorStrings.szStandard.Length - 1;
  4.  
  5. for (int i = 0; i < length; ++i)
  6. {
  7.     GameObject player = NGUITools.AddChild(grid, Resources.Load("Logic Button") as GameObject);
  8.    
  9.     player.name = PlayEditorStrings.szStandard[i];
  10.     player.GetComponentInChildren<UILabel>().text = PlayEditorStrings.szStandard[i];
  11. }
  12.  

And here is what I am calling on OnApplicationQuit()

  1. GameObject grid = GameObject.Find("Logic Grid");
  2.  
  3. if (grid != null)
  4. {
  5.     Transform trans = grid.transform;
  6.  
  7.     while (trans.childCount > 0)
  8.     {
  9.         NGUITools.Destroy(trans.GetChild(0).gameObject);
  10.     }
  11. }

However, none of the objects are ever being destroyed, and will pile up if I run it multiple times.

I was doing something similar with UILabel prefabs, and it works fine, but using a simple button made as a prefab doesn't work.

Pages: [1]