Hi All
Iam trying to import textures manually from a text file with the code:
Texture2D ImportTexture(string path)
{
string destpath = System.IO.Directory.GetCurrentDirectory() + "/";
System.IO.Directory.CreateDirectory(Path.GetDirectoryName(assetPath) + "/Textures");
string assetpath = Path.GetDirectoryName(assetPath) + "/Textures/" + Path.GetFileName(path);
File.Copy(path, destpath + assetpath, true);
AssetDatabase.Refresh();
return (Texture2D)AssetDatabase.LoadAssetAtPath(assetpath, typeof(Texture2D));
}
The problem being the textures get added and show up in Unity but the method LoadAssetAtPath returns a 'null' even though the texture is there, but oddly if I do a reimport then LoadAssetAtPath works fine and returns the Asset. Am I missing a step somewhere? Thanks Chris