疑似发现cocos 3.8.7的预制体bug

我有个预制体叫LongButton,上面挂载了CustomButton的组件,可以支持在编辑器里通过下拉菜单切换按钮的风格。但是实际运行时并没有切换,还是用的预制体的原生配色。

可以看到图1设置了2个蓝色,其中上面的是预制体,下面的取消了预制体。进入游戏之后,上面的恢复了预制体默认的颜色,下面用的是正确的颜色。

    @property({ type: Enum({ Custom: 1, Default: 2, Main: 3, Warning: 4, Light: 5, Hint: 6 }), tooltip: '按钮样式' })
    public buttonStyle: number = 1;

    update() {
        // @ts-ignore
        if (!CC_EDITOR){
            return;
        }
        const currentButtonStyle = this.numberToButtonStyle(this.buttonStyle);
        if (this._buttonStyle !== currentButtonStyle) {
            this._buttonStyle = currentButtonStyle;
            this.setButtonStyle(currentButtonStyle);
        }
    }


image

        if (!CC_EDITOR){
            return;
        }

这个没问题啊,只有编辑器状态下才需要一直刷新,而且已经把预制体的内容修改了。而且代码不变,只把预制体取消链接,进入游戏之后他就是蓝色的。

你注释掉这个return 呢?

我也遇到过,是换图集资源,可是按钮仍然是上个图集的图片,后面重启下就好了

@executeInEditMode(true) 这个装饰器加了没有

加了,不然我在编辑器改不会生效

这么一说我这张图确实在AutoAtlas里……