How to edit material at runtime?

I’m working on a plugin in which I want to be able to get a material at runtime and edit its properties.

All that I’ve been able to find is people using:

static ConstructorHelpers::FObjectFinder<UMaterial> MatFinder(TEXT("Material'/Game/Content/MaterialTest.MaterialTest'"));

But I don’t want to access the Material in a constructor and my plugin file does not inherit from UObject.

Any thoughts on where should I start?

Haven’t tried loading a material specifically but you could have a look at StaticLoadObject(), e.g.

// Asset path in content browser - you could also dynamically build this string
FString path = TEXT("Material'/Game/Content/MaterialTest.MaterialTest'");

// Use StaticLoad to load the object
UMaterial* mat = Cast<UMaterial>(StaticLoadObject(UMaterial::StaticClass(), NULL, *path));

if (mat )
	// Do something

I tried this but I always get

LogLinker:Warning: Can't find file '/Game/Content/Mesh/Ddo/NewMaterial'
LogLinker:Warning: Can't find file '/Game/Content/Mesh/Ddo/NewMaterial'
LogUObjectGlobals:Warning: Failed to find object 'Material /Game/Content/Mesh/Ddo/NewMaterial.NewMaterial'

I have no idea what I’m doing wrong.

This is how I was able to make it work.

FString matPath = "Material'/Game/MasterMaterial.MasterMaterial'";
    UMaterialInterface * material = Cast<UMaterialInterface >(StaticLoadObject(UMaterialInterface::StaticClass(), nullptr, *(matPath)));
    if (material)