BGE错误:' VideoTexture.Texture'对象没有属性' materialID'

时间:2018-04-13 18:16:28

标签: python blender attributeerror videotexture

我尝试在混合器游戏引擎中更改对象的纹理。 我认为使用Video Texture (bge.texture)中的纹理替换是个好主意。 我试着运行以下脚本:

def createTexture(cont):
    obj = cont.owner

    # get the reference pointer (ID) of the internal texture
    ID = texture.materialID(obj, 'Kraftwerk2.png')

    # create a texture object
    object_texture = texture.Texture(obj, ID)

    # create a new source with an external image
    url = logic.expandPath(new_file)
    new_source = texture.ImageFFmpeg(url)

    # the texture has to be stored in a permanent Python object
    logic.texture = object_texture

    # update/replace the texture
    logic.texture.source = new_source
    logic.texture.refresh(False)

def removeTexture(cont):
    """Delete the Dynamic Texture, reversing back the final to its original state."""
    try:
        del logic.texture
    except Exception as e:
        print(e)

但它失败并显示以下错误消息:

  

Python脚本错误 - 对象' Plane',控制器' Python':Traceback   (最近一次调用最后一次):文件   " F:\ Benutzer \默林\ MW-工业\搅拌机   Dateien \ Cinema \ Render-Blend \ MoonSpace.ble nd \ Test.py",第19行,in   createTexture AttributeError:' VideoTexture.Texture'对象没有   属性' materialID'

有没有办法解决问题?

0 个答案:

没有答案