Dynamically constructed MediaTexture objects do not function properly

There seems to be a problem with dynamically constructed MediaTexture objects. I entered a bug about this, and found another report on AnswerHub, but I thought I’d drop this here so anyone else having issues with it will hopefully hit it and save themselves some time. Or maybe I’m doing something wrong (though if so, it must be something very obscure) and someone here will point it out.

Basically, if you have a MediaTexture that you’re trying to use as a material texture parameter, it will only function if the MediaTexture you’re assigning it is created as an asset. It will not work if you dynamically create the MediaTexture at runtime by using Construct Object From Class.

To boil this down for a test case, I made the following material called MediaMaterial:

Then I created a cube and added a blueprint to it. That blueprint looked like this:

I created a second cube using the same blueprint. I then created an empty MediaTexture asset, without filling in any information about it. I assigned it to the property TheTexture on the first cube and left the second cube blank.

I’m not sure it’s significant, but I added some extra debugging on and found that the passed-in MediaTexture had Height and Width of 2 and Aspect Ratio of 1, but the dynamically created one had zeros for all of the above. And after the video is loaded, the passed-in one had the appropriate video height/width/AR and the dynamically created one still had 0.

Launching it shows the video playing on the first cube, but not the second (which should have created the missing texture in the blueprint). Other than dynamically creating the texture, everything else is done identically for both cubes. This seems to show that there’s something broken with MediaTextures that are created dynamically. Or I’m doing something wrong. Would love for it to be the latter, because then I could just fix my code. Of course, it would also be troubling because it makes me question how many other non-obvious things I’ll run into.

Project on dropbox: Dropbox - File Deleted

Answerhub here: https://answers.unrealengine.com/que…cts-do-no.html

It made it into the bug system: Unreal Engine Issues and Bug Tracker (UE-89272)