Skip to content

Instantly share code, notes, and snippets.

@naruse
Created November 11, 2014 23:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naruse/79d54c660707ed717edd to your computer and use it in GitHub Desktop.
Save naruse/79d54c660707ed717edd to your computer and use it in GitHub Desktop.
public List<Texture> GetTextures2D(Material mat) {
List<Texture> list = new List<Texture>();
int count = ShaderUtil.GetPropertyCount(mat.shader);
for(int i = 0; i < count; i++) {
if(ShaderUtil.GetPropertyType(mat.shader, i) == ShaderUtil.ShaderPropertyType.TexEnv) {
if(ShaderUtil.GetTexDim(mat.shader, i) == ShaderUtil.ShaderPropertyTexDim.TexDim2D) {
list.Add(mat.GetTexture(ShaderUtil.GetPropertyName(mat.shader, i)));
}
}
}
Debug.Log("Textures:" + list.Count + " total properties: " + count);
return list;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment