diff --git a/engine/src/core/com/jme3/material/MatParamTexture.java b/engine/src/core/com/jme3/material/MatParamTexture.java index 0989cc157..8bce967fc 100644 --- a/engine/src/core/com/jme3/material/MatParamTexture.java +++ b/engine/src/core/com/jme3/material/MatParamTexture.java @@ -62,6 +62,15 @@ public class MatParamTexture extends MatParam { this.value = value; this.texture = value; } + + @Override + public void setValue(Object value) { + if (!(value instanceof Texture)) { + throw new IllegalArgumentException("value must be a texture object"); + } + this.value = value; + this.texture = (Texture) value; + } public void setUnit(int unit) { this.unit = unit; @@ -85,6 +94,8 @@ public class MatParamTexture extends MatParam { super.write(ex); OutputCapsule oc = ex.getCapsule(this); oc.write(unit, "texture_unit", -1); + + // For backwards compat oc.write(texture, "texture", null); } @@ -93,6 +104,7 @@ public class MatParamTexture extends MatParam { super.read(im); InputCapsule ic = im.getCapsule(this); unit = ic.readInt("texture_unit", -1); - texture = (Texture) ic.readSavable("texture", null); + texture = (Texture) value; + //texture = (Texture) ic.readSavable("texture", null); } } \ No newline at end of file