How to change texture for a material at runtime

I am working on some special case cubemaps. I have single materials (applied to numerous meshes) that I would like to change their cubemap texture at runtime. I have read that UMaterialInstanceDynamic is the way to go, but I would prefer just to modify the UMaterialInstance (a UMaterialInstanceConstant) as I have easy access to the material (as opposed to all the meshes).

I’ve looked through the UMaterialInstanceDynamic (in game) and UMaterialInstanceConstant (in editor) and they both eventually call UMaterialInstance::SetTextureParameterInternal when attempting to modify the texture at their appropriate runtime (game/editor). So I commented out the #if WITH_EDITOR in UMaterialInstanceConstant and my tests indicate that forcing UMaterialInstanceConstant to call SetTextureParameterInternal (both in editor and in game) results in the texture being changed as I desired.

The question I have is why is UMaterialInstanceConstant only a WITH_EDITOR class when the various set parameters actually work in game?

Any ideas?

Anyone know why UMaterialInstanceConstant is being debilitated?

Is this too challenging a question? :slight_smile:

So far the most similar UE4 AnswerHub question/response was this: [C++] Changing alpha of a Material at runtime? - Rendering - Epic Developer Community Forums

Can someone at Epic address this issue?

i also have this sort of a problem. works perfectly in editor but when i package it, it wont work.