# How do I change material properties?

**URL:** <https://forums.unrealengine.com/t/how-do-i-change-material-properties/310793>\
**Category:** Rendering\
**Tags:** unreal-engine, crash, question, CPP\
**Created:** [March 13, 2015, 11:22am UTC](https://forums.unrealengine.com/t/how-do-i-change-material-properties/310793 "2015-03-13T11:22:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![PedroCosta](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@PedroCosta](https://forums.unrealengine.com/u/PedroCosta)\
**Post date:** [March 13, 2015, 11:22am UTC](https://forums.unrealengine.com/t/how-do-i-change-material-properties/310793/1 "2015-03-13T11:22:03Z")

</div>

Hi there. I want to create an actor class, attach a static mesh to it with a specific color. I want to be able to drag the class to the editor and have the mesh automatically assume that color. Also, I’d like to have a property exposed that would let anyone control the material’s color without having to go to blueprints.

I tried creating a material instance for the mesh in the class constructor and that works well.  
But if I try changing the color of that material in the constructor the editor crashes.  
Any thoughts?

---

<div class="post-metadata">

**Author:** ![PedroCosta](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@PedroCosta](https://forums.unrealengine.com/u/PedroCosta)\
**Post date:** [March 13, 2015, 12:14pm UTC](https://forums.unrealengine.com/t/how-do-i-change-material-properties/310793/2 "2015-03-13T12:14:35Z")

</div>

Thanks for the reply cancel. I had tried to do so in both. Doing it in BeginPlay or PostInitializeComponents does indeed prevent the crash in the editor. But if I do it in BeginPlay, the material only assumes the color when I hit play. If I do it in PostInitializeComponents, it assumes the color in the editor. However, if I change the color in the code, it’s not reflected on the editor.
