setMaterial works unexpected. [BUG]?

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));
        rendComp.setMaterial(0, cc.Material.createWithBuiltin('2d-gray-sprite', 0));

Result is

Hi, you can refer to this document:

If still not resolved, can you provide a demo that reproduces the problem?

Thanks, it works fine.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.