Hi,
Try to add onclick event to instatiated button at runtimr but still not work, it’s always the last value, I have added variable inside of the lambda…
string[] shots;
shots = System.IO.Directory.GetFiles (scene.name, "*.png");
foreach (string item in shots)
{
string tmp = item;
Debug.Log ("Found: " + tmp);
inst = Instantiate(thumbnailPrefab) as GameObject;
inst.transform.parent = layoutParent.transform;
inst.transform.localScale = layoutParent.transform.localScale;
inst.GetComponent<Image>().sprite = SpriteFromPath(tmp);
Button newButton = inst.GetComponent<Button>();
newButton.onClick.AddListener(() => ThumbToBig(System.IO.Path.GetFileName(tmp)));
}
any idea ? thanks