Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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

http://docs.unity3d.com/Documentation/ScriptReference/AssetPostprocessor.OnPreprocessTexture.html

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;
        }
    }
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.