- Home /
Dynamically create Texture2D that is readable
I want to create a Texture2D dynamically which is readable. There doesn't appear to be any way to set the IsReadable property to true. The docs reference IsReadable, but I can't even find it declared anywhere. I have
Texture2D tex = new Texture2D(width, height, TextureFormat.RGB24, false);
The size of the Texture is runtime dependent, and so I can't create it using a TextureImporter. I also can't clone an existing Texture2D which is readable because I need to change the size.
Thanks
I'm having the exact issue. I need to find the "IsReadable" flag because I'm using SetPixels() but I can't find it anywhere. I don't understand :(
Correction, I'm using GetPixels() which require IsReadable. I checked the "Read/Write Enabled" check box in the Texture Importer but it still causes the same error.
Answer by Eric5h5 · Apr 20, 2011 at 10:44 PM
Your code is fine; you don't need to do anything extra.
Answer by sendel76 · Sep 12, 2011 at 10:40 PM
Having the same issue.
protected static void makeReadable(Texture2D [] textures, bool enabled ) { foreach (Texture2D texture in textures)
{ string path = AssetDatabase.GetAssetPath(texture); TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter; textureImporter.isReadable = enabled;
AssetDatabase.ImportAsset(path); } }
this does not help since I created a new Texutre. I want to save this new Texture as PNG - but it says that I cannot save it because read is not enabled.
so... bummer.
Your answer
Follow this Question
Related Questions
My Dynamic texture not showing up in the Build??? 0 Answers
How to get player's face onto character mesh 1 Answer
Update Texture type to GUI during runtime 0 Answers
Loading a www texture makes my game freeze for a second 1 Answer
Why is NativeArray always shorter than the number of pixels in the texture? 1 Answer