Restoring dynamic material instance after hot reload


I have a class, TileGrid, which spawn (in it’s constructor as this is the only way to achieve what I want) a number of Tile class instances, and attaches them to itself. Each tile class then has a StaticMeshComponent, and when I set a material parameter on the parent TileGrid, they are each updated so that their StaticMeshComponents have CreateAndSetMaterialInstanceDynamicFromMaterial called on them with this material (each Tile sets different material parameters).

Everything was running fine, but I’ve found that a hot reload causes the materials to revert to default. Notably the following is output:

Re-instancing UGTile after hot-reload.

And the material of each and every Tile go to default. But not their individually set StaticMeshComponents.

Ideally I would like the material instances to restore like the meshes do. I’ve also tried calling CreateAndSetMaterialInstanceDynamicFromMaterial on PostInitProperties(), but this causes a null-pointer exception as each tile tries to access the TileGrid object (which is set as each Tile’s owner… I would think that this pointer would be restored correctly by the time PostInitProperties() is run?).

Any help very much welcome. Maybe there’s a better function to call, or an obvious reason why the owner is resolving to null briefly. Or hopefully there is some simple way to make sure that the dynamic material instance restores correctly.