Quantcast
Channel: Questions in topic: "readable"
Viewing all articles
Browse latest Browse all 62

Issues with setting TextureImporter isReadable in script

$
0
0
I am using the free version of unity and have a c# script that I wrote to auto save a displayed texture every N seconds. I am using TextureIMporter to set the assets isReadable to true so that I can call texture.EncodeToPNG(), see code segment: string path = AssetDatabase.GetAssetPath(tex); TextureImporter texImporter = AssetImporter.GetAtPath(path) as TextureImporter; texImporter.isReadable = true; AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate); if(texImporter.isReadable == true){ File.WriteAllBytes(Application.dataPath + "/Resources/backdrop.png", tex.EncodeToPNG()); Debug.Log("This should have saved"); }else{ Debug.Log("FALSE"); } The issue is that this does not always work? For testing I have this in a coroutine that is called every N seconds, but isReadable is not always set as true? Suppose the texture (tex in above code) is the same then it works every other time. The first time it sets true the second false the third true etc. Any insight would be helpful? Why shouldn't work every time?

Viewing all articles
Browse latest Browse all 62

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>