Fix error when replacing textures