This may be a bug or just my lack of knowledge.
I’ve attached a blend plus some textures to demonstrate an issue with dynamically changing textures that is apparent in 2.78, UPBGE and 2.79 TextureCycler.zip (968 KB). Also refer to the code below.
The point of the example is that on a 50-tick delay the texture of a cube should cycle among the three textures in the directory: a grass texture, a color grid and a tile pattern.
What actually happens is that every second change reverts back to the original texture of the cube which happens to be the blender gray grid pattern. Note that grey grid pattern is never referenced in the code.
If anyone can explain why this happens I would love to know.
import bge def doCycle(cont): obj=cont.owner tex=pickTex(obj['iter']) if obj['iter']<2: obj['iter']+=1 else: obj['iter']=0 changeTexture(obj,tex) def pickTex(i): if i==0: tex="grass" if i==1: tex="colorGrid" if i==2: tex="Tile" return tex def changeTexture(owner,tex): path = bge.logic.expandPath("//"+tex+".png") imageSource = bge.texture.ImageFFmpeg(path) imageSource.refresh() object_texture = bge.texture.Texture(owner, 0,0) # points to 0th material slot, 0th texture slot object_texture.source = imageSource # SHOULD assign image each time but flip flops back to original texture object_texture.refresh(True) #store it owner["prop_+tex"] = object_texture # ==== read out print (path)