※以下のようなコードで指定したい場合
ーーー
class MaterialSwitcher extends pc.ScriptType {
initialize() {
this.entity.button.on("click", this.changeMaterial, this);
}
changeMaterial() {
this.target.render.meshInstances[0].material = this.material.resource;
}
}
class MaterialSwitcher extends pc.ScriptType {
initialize() {
this.entity.button.on("click", this.changeMaterial, this);
}
changeMaterial() {
this.target.render.meshInstances[0].material = this.material.resource;
}
}
ーーー
上記のように、
AttributeからMaterialを設定したものではなく、AssetsにあるMaterialを直接設定する場合
当プロジェクトのAssetsを参照するには、 `this.app.asset.find` を使って使用することができます。
これを使用する際に、該当のAssetsがPreloadしていない場合は一度Loadする必要があるのでご留意ください。
https://developer.playcanvas.com/en/api/pc.Asset.html#ready
コメント
0件のコメント
サインインしてコメントを残してください。