Accessing all textures from a given material

Is there a way to loop through all textures in a material, like

foreach( Texture t in material.textures) …?

I dont know the texture names to use with material.GetTexture(propertyName), as they are different for each shader, and also I dont have a list of all properties in a given material. I want a dynamic way to do this, not storing all slot names in a hardcoded dictionary or something like this.

How can I do that?

Thanks!!

Coluna

I think that should be an easy way, since the material inspector already show ALL properties, and it was told that the inspector is done using Unity API…any idea?

I would like some help with this too.
A brute-force attack using “hasproperty” does not sound like a good idea. :slight_smile:

[ ]s, gandhi

The number of textures is set by the shader. Unity doesn’t keep track of them collectively, so unfortunately, there isn’t a built-in way to iterate over them.