void GetAllImages() { texture2Ds.Clear(); savedImages.Clear(); DirectoryInfo dir = new DirectoryInfo(s); for (int i = 0; i < content.transform.childCount; i++) { Destroy(content.transform.GetChild(i)); } info = dir.GetFiles("*.png"); foreach (FileInfo f in info) { Debug.Log(f.Name); Texture2D texture = UploadImage.LoadPNG(s + f.Name); texture2Ds.Add(texture); GameObject g = Instantiate(savedImage, new Vector3(0, 0, 0), Quaternion.identity); g.transform.parent = content.transform; Image image = g.transform.GetComponent <Image>(); g.GetComponent <Button>().onClick.AddListener(delegate { SetFrameTexture(texture); }); Rect rec = new Rect(0, 0, texture.width, texture.height); image.sprite = Sprite.Create(texture, rec, new Vector2(0, 0), 1); savedImages.Add(g); } }