// Setup takes a title, a icon and the parent script. // Sets the gameobject variables and adds the onClick event. public void Setup(string title, Sprite icon, ButtonGroupPref parent) { ImageIcon.sprite = icon; TextField.text = title; this._parent = parent; Butncmp.onClick.RemoveAllListeners(); Butncmp.onClick.AddListener(HandleClick); }
// Creates a menu with the menu groups in the list. Also calls setup on all groups to instantiate their buttons and sub buttons. public void CreateMenu(List <MenuGroup> menuGroupList) { foreach (MenuGroup menuGrp in menuGroupList) { GameObject menuGroupPrefab = this.ButtonGroupPool.GetObject(); menuGroupPrefab.transform.SetParent(this.group); ButtonGroupPref btngrp = menuGroupPrefab.GetComponent <ButtonGroupPref> (); btngrp.Setup(menuGrp, this); } }
public void LeavePage() { while (this.group.childCount > 0) { GameObject toRemove = this.group.GetChild(0).gameObject; ButtonGroupPref test = toRemove.transform.GetComponent <ButtonGroupPref> (); test.ReturnChildren(); ButtonGroupPool.ReturnObject(toRemove); } this.gameObject.SetActive(false); }