import { _decorator, Component, Node, MeshRenderer, Material, resources } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('test')
export class test extends Component {

    start() {
    }

    onClick(){
        resources.load('default-material', Material, (err,res) => {
            if(err)return
            let meshRenderer = this.node.getComponent(MeshRenderer)
            if (meshRenderer) {
                let cres: Material = new Material()
                cres.copy(res)
                cres.onLoaded()
                meshRenderer.setMaterial(cres, 0)
            }
        })
    }

    update(deltaTime: number) {

    }
}

