public void AddUpgrade(Button[] tab, Vector4[] cornerTab, GameObject toInstantiate) { Button toInstantiateButton; for (int i = 0; i < tab.Length; i++) { toInstantiateButton = tab [i]; if ((i == 0 && !gm.HaveNoGuard()) || (i == 1 && !gm.HaveAllGuards())) { Button instance = ui.CreateInstance(toInstantiateButton.gameObject, new Vector2(cornerTab [i].x, cornerTab [i].y), new Vector2(cornerTab [i].z, cornerTab [i].w)); ui.TextMenu(toInstantiateButton.name, new Vector2(1f, 1f), new Vector2(0f, 0f), instance.gameObject, new Color(0, 0, 0)); if (i == 0) { instance.onClick.AddListener(ButtonLife); } else { instance.onClick.AddListener(ButtonGuard); } instance.transform.SetParent(toInstantiate.transform); } } }