If do it by hand in editor it works fine, but in runtime not. or am i doing something wrong?
CC 2.3.3, web.
So trying to setMaterial by this code below:
let isEnable = toggle.isChecked;
this.getComponentsInChildren(cc.RenderComponent).forEach( rendComp => {
if(isEnable === true)
rendComp.setMaterial(0, cc.Material.createWithBuiltin('2d-sprite', 0));
else
rendComp.setMaterial(0, cc.Material.createWithBuiltin('2d-gray-sprite', 0));
})
Result is