So, this code is supposed to set onclick events for each button, and each onclick event should have its own id. But, it makes so every button has the same onclick event with the same parameters. The parameter is always 2(there are 2 elements in the array).
[SerializeField] private Transform buttonsParent;
private void genButtons()
{
for (int i = 0; i < buttonsParent.childCount; i++)
{
buttonsParent.GetChild(i).GetComponent<Button>().onClick.RemoveAllListeners();
buttonsParent.GetChild(i).GetComponent<Button>().onClick.AddListener(delegate { itemPlacer.setId(i); });
}
}