Created
November 25, 2014 14:18
-
-
Save rafayali/fc717cb0b574d5dfaf1d to your computer and use it in GitHub Desktop.
Loading textures from an asset path in unity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string relativePathToAssets = "//GUI//productImages2//"; | |
List<Texture> LoadTextures () | |
{ | |
List<Texture> textures = new List<Texture>(); | |
string[] productImagesNames = Directory.GetFiles(Application.dataPath + relativePathToAssets, "*.jpg", SearchOption.AllDirectories); | |
foreach(string imagePath in productImagesNames){ | |
string relativeImagePath = ("Assets" + imagePath.Replace(Application.dataPath, "")).Replace("//","/"); | |
textures.Add(AssetDatabase.LoadAssetAtPath(relativeImagePath, typeof(Texture)) as Texture); | |
} | |
return textures; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment