const { ccclass, requireComponent } = cc._decorator; @ccclass @requireComponent(cc.Sprite) export default class ShaderGray extends cc.Component { onLoad() { this.getComponent(cc.Sprite).setMaterial(0, cc.Material.getBuiltinMaterial('2d-gray-sprite')); } }