Mesh Proxy: getTextureName

getTextureName(matID)
  • Returns the name of the texture in the 1st texture slot on a material.

Return Type: 

  • string

matID:
  • Type = integer
  • 0 = first material on mesh
  • 1 = second material on mesh
  • 2 = third material on mesh
  • etc.
    Note:
    • Returns Null if there isn't a texture in the first texture slot.
       
    • Returns the name of  texture and not the name of the texture slot.  In other words, if the the first texture slot named Tex1 holds an image named oak_leaf.jpg, it will return IMoak_leaf.jpg
       
    • Materials on the mesh have to be assigned to different faces on the mesh. 
       
    • If a material is assigned to same faces as another material, only the first material name will be returned.
    Sample Code

    ############################# get the texture name

    # import bge
    import bge

    # get the current controller
    cont = bge.logic.getCurrentController()

    # get object that owns this controller
    obj = cont.owner
     
    # Get a list of the mesh
    meshList = obj.meshes

    # Get the first mesh on the object
    mesh = meshList[0]
     
    # get first material
    matID = 0

    # get the name of the 1st texture 
    textureName = mesh.getTextureName(matID)