On existing empty material, creating UE MaterialEditor nodes from c++ wont show any changes on material preview even if nodes are properly created and connected.
But if existing material had some connected nodes the update works properly.
Below is my code, but I tried a lot of other things like RebuildGraph(), link, refresh… So much in fact that even AI gave up.
SelectedMaterial->Modify();
SelectedMaterial->PreEditChange(nullptr);
// create nodes
UMaterialExpression* a = UMaterialEditingLibrary::CreateMaterialExpression(SelectedMaterial,UMaterialExpressionTextureSample::StaticClass());
UMaterialExpressionTextureSample* TextureSample =Cast<UMaterialExpressionTextureSample>(a);
SelectedMaterial->AddExpressionParameter(TextureSample,SelectedMaterial->EditorParameters);
TextureSample->Texture = TextureGroups[SelectedMaterialName][0].Texture;
// connect
SelectedMaterial->GetEditorOnlyData()->BaseColor.Connect(0,TextureSample);
SelectedMaterial->PostEditChange();
UMaterialEditingLibrary::RecompileMaterial(SelectedMaterial);