Well, I'm stumped.
My script is attempting to change the image used by a DzImageProperty (it's a DzBrickMaterial, I iterate through the property list and find the matching property name.)
So I've got a reference to DzApp::DzImageMgr, and I'm calling getImage(newtexturefilename) to get the new DzTexture. That seems to work....then I call setValue() on the DzImageProperty.
No errors, but it doesn't change in the scene. The image list doesn't show the new image in it either. The property doesn't change. I've tried debugging it, but with the debugger stepping through, the new DzTexture from the DzImageMgr gets deleted before I can do anything.
Here are the two significant parts of the script: First, the main part where I then call a second part....
// newfn now has the name of the texture to switch to
// and filename has the current filename
var newfninfo = new DzFileInfo(newfn);
if(newfninfo.exists)
{
var ImgMgr = App.getImageMgr();
var checkImage = ImgMgr.findImage(newfn);
if(checkImage)
{
// the image is already loaded. Set the current Material
SetMaterialTextureByType(mat,type,checkImage);
}
else
{
// the image isn't loaded.
var newTex = ImgMgr.getImage(newfn);
SetMaterialTextureByType(mat,type,newTex);
}
print("Set " + mat.name + " " + GetTextureTypeStr(type) + " to " + newfn);
}
And here is the pertinent part of SetMaterialTextureByType(m, type, tex)
case textype.brick:
for(var i = 0; i < m.getNumProperties(); i++)
{
var bp = m.getProperty(i);
if(bp.inherits("DzImageProperty"))
{
var bpv = bp.getValue();
if(bpv.inherits("DzTexture"))
{
var tn = tex.name; print("Texture name: " + tn);
if(tex.isNull) { print("Texture deleted before it could be set!"); break; }
if(bpv.name == tex.name)
{
bp.setValue(tex);
break; //i = m.getNumProperties();
}
}
}
}
break;
I should add that for when it's not a brick, SetMaterialTextureByType() goes through the types it has from DzDefaultMaterial, and calls the various 'set' members.....but that doesn't appear to work EITHER. (i.e., the image was a "base color" image map, so it is set using materialObj.setColorMap(newTex);
So what am I either missing, or getting wrong?