其他
如何在 Creator3D 中切换模型贴图,超级简单
"test")
export class test extends Component {
({type: Texture2D })
texture1: Texture2D = null;
(Texture2D)
texture2: Texture2D = null;
}
(swithcTextue() {
//获取ModelComponent组件
let modelComponent = this.getComponent(ModelComponent);
//获取0号材质
let material = modelComponent.materials[0];
//获取纹理
let texture = material.getProperty('mainTexture');
//设置纹理
material.setProperty('mainTexture', texture === this.texture1 ? this.texture2 : this.texture1);
}
点个赞,证明你还爱我