标签:load number ttext text ram material scene png image
一: 关键是找到材质对象(laya.d3.core.material.BlinnPhongMaterial)1,Unity数据
①, 在scene中的结构(注意我们只获取PlayerModel对象)
②,PlayerModel的属性
1, Unity数据
①,以预制的方式导出
②, 结构如下
2, 获取PlayerModel
this.prefabPlayer = (Laya.Loader.getRes(`3d/model/Conventional/model.lh`) as Laya.Sprite3D).getChildAt(0) as Laya.Sprite3D;
三: 获取laya.d3.core.material.BlinnPhongMaterial
let $mash: Laya.MeshSprite3D = this.owner as Laya.MeshSprite3D;
this._material = $mash.meshRenderer.material as laya.d3.core.material.BlinnPhongMaterial;
注意: this.owner就是this.prefabPlayer
/**
* 更换贴图
* @param $textureID
*/
public resetTexture( $textureID: number ): void{
if( !this._material ) return;
this._material.albedoTexture = Laya.Loader.getRes(`3dmodeltexture/mt_${$textureID}.png`);
}
结果:
标签:load number ttext text ram material scene png image
原文地址:https://blog.51cto.com/aonaufly/2512025