BetterList< Transform > childs = subMaterialGrid.GetComponentInChildren<UIGrid> ().GetChildList ();
if (childs.size > 0) {
for (int i = 0; i < childs.size; i++) {
DestroyImmediate (childs [i].gameObject);
}
}
GClasses.MaterialConfig[] availableTextures = book_manager.GetComponent<book_manager> ().getAvailableTexturesForMaterial (sender.GetComponent<MaterialData> ().materialName ());
for (int i = 0; i < availableTextures.Length; i++) {
GameObject button = NGUITools.AddChild (subMaterialGrid, subMaterialbuttonPrefab);
button.GetComponentInChildren<MaterialData> ().setMaterialConfig (availableTextures [i]);
button.GetComponentInChildren<UILabel> ().text = availableTextures [i].description;
button.GetComponentInChildren<UILabel> ().gameObject.AddComponent<UIDragScrollView> ();
UIEventListener.Get (button.GetComponentInChildren<UILabel> ().gameObject).onClick += textureSelected;
button.GetComponentInChildren<UITexture> ().mainTexture = Resources.Load ("Textures/Buttons/btn_" + availableTextures [i].texture_name) as Texture;
button.GetComponentInChildren<UITexture> ().depth = 5;
}
subMaterialGrid.GetComponentInChildren<UIGrid> ().Reposition ();