# Change material of asset type render through code

**URL:** <https://forum.playcanvas.com/t/change-material-of-asset-type-render-through-code/36177>\
**Category:** Help & Support\
**Tags:** ui, editor, scripting, shaders\
**Created:** [July 1, 2024, 3:41pm UTC](https://forum.playcanvas.com/t/change-material-of-asset-type-render-through-code/36177 "2024-07-01T15:41:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hassan\_Amjad1](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/hassan_amjad1/32/22404_2.png) [@Hassan\_Amjad1](https://forum.playcanvas.com/u/Hassan_Amjad1)\
**Post date:** [July 1, 2024, 3:41pm UTC](https://forum.playcanvas.com/t/change-material-of-asset-type-render-through-code/36177/1 "2024-07-01T15:41:59Z")

</div>

Hi,  
How can I change material of asset type render through code?

 ![image](https://forum-files-playcanvas-com.s3.dualstack.eu-west-1.amazonaws.com/original/3X/8/9/89f4715b6f1eadb42cd882b13e6037b23436c9b2.png)

@Leonidas@yaustar

We are using render type asset, it is working for any other type except this

---

<div class="post-metadata">

**Author:** ![robert.ua](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/robert.ua/32/29748_2.png) [@robert.ua](https://forum.playcanvas.com/u/robert.ua)\
**Post date:** [July 1, 2024, 11:12pm UTC](https://forum.playcanvas.com/t/change-material-of-asset-type-render-through-code/36177/2 "2024-07-01T23:12:51Z")

</div>

Have you tried changing the material on each mesh instance of this render?

```javascript
for(const meshInstance of this.entity.render.meshInstances){
    meshInstance.material = this.materialAsset.resource; // set your material
}

```
