//-- First, iterate through the grid, and remove any children that are present... List<Transform> lstChildren = new List<Transform>(); foreach(Transform oChild in oGridTransform) { lstChildren.Add(oChild); } oGridTransform.DetachChildren(); foreach(Transform oTransform in lstChildren) { oTransform.gameObject.SetActive(false); DestroyImmediate(oTransform.gameObject); }
What am I missing?
Why isn't there an NGUITools.RemoveChild()?
Title: Re: Remove and destroy children from a grid? (Candidate for NGUITools?)
Post by: ArenMook on January 05, 2014, 09:00:22 AM
And here is what I am calling on OnApplicationQuit()
GameObject grid = GameObject.Find("Logic Grid");
if(grid !=null)
{
Transform trans = grid.transform;
while(trans.childCount>0)
{
NGUITools.Destroy(trans.GetChild(0).gameObject);
}
}
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.
Title: Re: Remove and destroy children from a grid? (Candidate for NGUITools?)
Post by: chad on January 07, 2014, 05:52:54 PM
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.
Title: Re: Remove and destroy children from a grid? (Candidate for NGUITools?)
Post by: hexaust on April 14, 2014, 09:16:14 AM
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.
Can I ask how did you fixed that issue? (my initialize function was being called again after the OnApplicationQuit call)