- Home /
find type of asset by path? (to check if file is Texture2D?)
GetFiles returns a list of strings[] of asset paths, and i have girl_hair.tga.meta, i wish to check if an asset is a texture at given path prior to loading it to a tex2d.
how can i?
Comment
Answer by frogsbo · Sep 08, 2014 at 04:54 PM
did it this way in the end:
var title : String = Selection.activeGameObject.renderer.materials[1%Selection.activeGameObject.renderer.materials.length].mainTexture.name;
print("full name " + title);
var path1 = System.IO.Directory.GetFiles(Application.dataPath, title+"*", System.IO.SearchOption.AllDirectories);
for (path1i in path1)
{
var last3chars : String = path1i.Substring(path1i.Length - 3);
if (last3chars != "eta" && last3chars != "mat" )
{retrievepath = path1i ; }
}
just returns files with same name that aren't .meta and .mat could search if the are finish in jpg,iff,gif, etc