Finding out if a Texture is Readable when Editor Scripting for Unity3D

There is a really simple way to find out if a Texture2D is readable when you’re doing an editor script. It took me longer than I expected so I thought I’d blog about it so others might find it easier in the future…

Texture2D myTexture2D;
string texturePath = AssetDatabase.GetAssetPath(myTexture2D);
TextureImporter textureImporter = (TextureImporter)AssetImporter.GetAtPath(texturePath);
if(textureImporter.isReadable)
{
	//have some fun!
}

It’s pretty simple and something you really need to know if you want to mess with the textures inside the Unity3D editor.