Select an actor with mouse click and call actor's class function with UMG button c++

Then get a reference to object under the mouse cursor. Do this in a player controller:

.
In buttons click event get cast the first pc to your own and call BlueprintCallable function(or just bp function) that will actually change material.