public void CreateFirstButton() { foreach (C_NavigationObj son in firstlayer) { Button btn = Instantiate(buttonPrefab, menu.GetChild(0)); btn.transform.name = son.name; btn.GetComponentInChildren <Text>().text = son.name; C_NavigationBtn objBtn = btn.GetComponent <C_NavigationBtn>(); objBtn.manager = this; objBtn.obj = son; objBtn.AddClickListener(); } }
/// 点这个物体,出他的子菜单 public void CreateButton(C_NavigationObj obj) { int layer = obj.layer; Transform parent = panelS[layer]; foreach (C_NavigationObj son in obj.sonS) { Button btn = Instantiate(buttonPrefab, parent); btn.transform.name = son.name; btn.GetComponentInChildren <Text>().text = son.name; C_NavigationBtn objBtn = btn.GetComponent <C_NavigationBtn>(); objBtn.manager = this; objBtn.obj = son; objBtn.AddClickListener(); //btn.onClick.AddListener(()=>Show(obj)); } }