public void TextureSelected(TextureEntry te)
 {
     if (currentTextureEntry != null)
     {
         currentTextureEntry.GetComponentInChildren <Text> ().text = "";
     }
     currentTextureEntry = te;
     currentTextureEntry.GetComponentInChildren <Text> ().text = "selected";
 }
        public void UpdateTextures()
        {
            string        folder = dataSaveLoad.GetFolderPath(textureFolder);
            DirectoryInfo di     = new DirectoryInfo(folder);

            List <string> files = new List <string>();

            foreach (string exp in new string[] { "*.jpg", "*.png" })
            {
                files.AddRange(System.IO.Directory.GetFiles(folder, exp));
            }
//			foreach (string f in files) {
//				print (f);
//			}

            TextureEntry[] entries = scrollContent.GetComponentsInChildren <TextureEntry> ();
            foreach (TextureEntry te in entries)
            {
                Destroy(te.gameObject);
            }

            //creating blank texture entry for reseting
            {
                GameObject pip = GameObject.Instantiate(texturePrefab);
                pip.transform.SetParent(scrollContent.transform, false);
                TextureEntry te = pip.GetComponentInChildren <TextureEntry> (true);
                te.TexturePath = null;

                te.GetComponentInChildren <Button> ().onClick.AddListener(() => {
                    TextureSelected(te);
                });
            }

            //creating each texture entries
            foreach (string f in files)
            {
                GameObject pip = GameObject.Instantiate(texturePrefab);
                pip.transform.SetParent(scrollContent.transform, false);
                TextureEntry te = pip.GetComponentInChildren <TextureEntry> (true);
                te.TexturePath = f;

                te.GetComponentInChildren <Button>().onClick.AddListener(() => {
                    TextureSelected(te);
                });
            }
        }