// Token: 0x060001DE RID: 478 RVA: 0x0001F0A4 File Offset: 0x0001D2A4 public static T AddChild <T>(GameObject parent) where T : Component { GameObject gameObject = NGUITools.AddChild(parent); gameObject.name = NGUITools.GetName <T>(); return(gameObject.AddComponent <T>()); }
/// <summary> /// Draw a button + object selection combo filtering specified types. /// </summary> static public void Draw <T> (T obj, OnSelectionCallback cb, params GUILayoutOption[] options) where T : MonoBehaviour { #if NGUI_3_5_8 Draw <T>(NGUITools.GetTypeName <T>(), obj, cb, options); #else Draw <T>(NGUITools.GetName <T>(), obj, cb, options); #endif }
static public void AddPanel() { GameObject go = SelectedRoot(); if (NGUIEditorTools.WillLosePrefab(go)) { NGUIEditorTools.RegisterUndo("Add a child UI Panel", go); GameObject child = new GameObject(NGUITools.GetName <UIPanel>()); child.layer = go.layer; Transform ct = child.transform; ct.parent = go.transform; ct.localPosition = Vector3.zero; ct.localRotation = Quaternion.identity; ct.localScale = Vector3.one; child.AddComponent <UIPanel>(); Selection.activeGameObject = child; } }
/// <summary> /// Draw a button + object selection combo filtering specified types. /// </summary> static public void Draw <T> (T obj, OnSelectionCallback cb, params GUILayoutOption[] options) where T : MonoBehaviour { Draw <T>(NGUITools.GetName <T>(), obj, cb, options); }
public void OnSet() { // for(int i=0;i<transform.childCount;i++) // { // Object.DestroyImmediate(transform.GetChild(i).gameObject); // } while (transform.childCount > 0) { Object.DestroyImmediate(transform.GetChild(transform.childCount - 1).gameObject); } // foreach(GameObject go in gos)Object.DestroyImmediate(go); // items = new List <GameObject>(); if (direction == Direction.Horizontal) { Table.columns = 0; } else { Table.columns = 1; } if (texts != null && texts != "" && atlas != null && font != null) { getTexts(); string[] strs = texts.Split(','); for (int i = 0; i < strs.Length; i++) { string str = strs[i]; // #if UNITY_EDITOR // NGUIEditorTools.RegisterUndo("Add a child UI Panel", transform.gameObject); // #endif GameObject child = new GameObject(NGUITools.GetName <UIPanel>()); // GameObject child = NGUITools.AddChild(transform.gameObject); // child.AddComponent<UIPanel>(); // child.name+=str; child.layer = transform.gameObject.layer; // child.transform.parent = Table.transform; child.transform.localScale = Vector3.one; BoxCollider collider = child.AddComponent <BoxCollider>(); child.AddComponent <UIEventListener>(); collider.size = new Vector3(w, h, 1); // child.transform // gos.Add(child); UISprite sprite = NGUITools.AddSprite(child, atlas, spriteName); //;NGUITools.AddWidget<UISprite>(child.transform.gameObject);// // sprite.transform.parent = child.transform; sprite.type = UISprite.Type.Sliced; // sprite.atlas=Resources.Load(atlas.name, typeof(UIAtlas)) as UIAtlas; // sprite.spriteName=spriteName; sprite.transform.localScale = new Vector3(w, h, 1); // sprite.transform.parent = child.transform; UIEventListener.Get(child).onClick = OnItemClick; UILabel label = NGUITools.AddWidget <UILabel>(child); label.font = font; label.text = str; label.transform.localScale = new Vector3(fontSize, fontSize, 1); label.transform.localPosition = new Vector3(0, 0, -1); child.transform.localPosition = new Vector3(0, 0, -1); if (IsOutline) { label.effectStyle = UILabel.Effect.Outline; } items.Add(child); } SelectedIndex = 0; } Table.repositionNow = true; //Table.Reposition(); }