- Home /
Determine the texture format at runtime.
Hello, I am trying to determine a texture format at runtime. It looks like the SDK doesn't expose textureFormat on the Texture or Texture2D object type. Is there any other way?
if(TextureFormat.ARGB32 == renderer.material.mainTexture.textureFormat) // compiler error
{
print("It is a ARGB32 Texture");
}
Answer by Eric5h5 · Aug 15, 2010 at 02:17 AM
You use Texture2D.format. If you look in the docs, you can see all the class variables and so on for Texture2D, so there's no need to guess.
Thank you very much. That was what i was looking for.
By the way, the reason I needed this is because the www class sometimes returns textures in ARGB format ins$$anonymous$$d of RGBA format. Anyways here is the revised code:
if(TextureFormat.ARGB32 == ((renderer.material.mainTexture as Texture2D).format)) { print("It is a ARGB32 Texture you will need to swizzle the colors."); }
Your answer
Follow this Question
Related Questions
Inverse of a texture for masking? 1 Answer
Loadimage Texture at runtime 1 Answer
Unsupported texture format 0 Answers
White Edges on Sprites Loaded from PNG at Run-time 0 Answers
How to set a texture resource to texture type "GUI" by script? 1 Answer