How to replace custom shader on material asset

Hello!

myScript.attributes.add(‘targetMaterial’, {
type: ‘asset’,
assetType: ‘material’
});

//then I create a custom shader

this.shader = new pc.Shader(gd, shaderDefinition);

//then I want to replace current shader of the targetMaterial Asset

this.material = this.targetMaterial.resource;

this.material.setShader(this.shader);

or

this.material.shader = this.shader;

this.material.update();

//But It seems to no avail, Plz help me , Appreciately