I am trying to automatically create a texture atlas from a set of generated png files in an Editor script. The problem is that I can't seem to be able to load a png into a Texture3D without it being inaccessible by the PackTextures method. I have tried a few different ways to load the PNGs, such as Resources.LoadAssetAtPath(...), AssetDatabase.LoadAssetAtPath(...) and a few more.

Since all of this is done in OnPostprocessAllAssets, I don't want to have to do any manual editing of the textures. I just want to be able to drop a PNG into a certain folder and get an updated atlas. Answers such as this seem to suggest manual editing.

The actual error message is

"Texture atlas needs textures to have Readable flag set!".

So the question is, is it possible to do this kind of post processing in Unity3D? Is there any way to import a PNG into a Texture2D with the Readable flag set, without having to manually change it?


1 Answer 1


Can you use the AssetPostprocessor to change the import settings of the textures in that particular folder?


http://docs.unity3d.com/Documentation/ScriptReference/TextureImporter.html http://docs.unity3d.com/Documentation/ScriptReference/TextureImporter-isReadable.html

class MyTexturePostprocessor extends AssetPostprocessor {
    function OnPreprocessTexture () {
        if (assetPath.Contains("atlas")) {
            var textureImporter : TextureImporter = assetImporter;
            textureImporter.isReadable = true;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .