How do I change material properties?

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?

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.