Is it possible for a Video on 2D screen

Hi, is it possible to play a video on the screen, 2D wise? so far i’ve only managed to play it on a 3D obj, but couldn’t seem to have it displayed on the 2D Screen, please advice.

Should be able to as an element has both a material and texture properties.

yea thats the thing. i tried using the element with the video texture/material on a 2D Screen, but nothing would appear. the video only plays on a 3D object that has the video texture/material

That’s interesting, @bestdenki7 can you post a simple sample project to take a look?

is this viable?

1 Like

i think i found the solution. i just had to add the world layer to it so it would render.

Nice! Yes, the UI layer is specially rendered to accommodate for certain UI features.

ahhh. thats good to know! thank you!

Here’s an example that I forked from the tutorial to work with the UI element without using the world layer on the element.


that is a really interesting way to do it, ill give it a try! thank you!
also a question; how should i be doing if i need to play various different videos? not simultaneously.

If they are all showing at the same time, create a texture per video and just assign it the same way.

If it’s the same texture but a different video source, I would probably remove the video DOM object and create a new one or try just changing video.src

Ultimately, it’s a video DOM object, a texture with the source set to the DOM object and the texture is then applied to anything that can take a texture object (materials, UI elements etc)

so many tv’s

thats really helpful thank you!
Sorry but, just a last question, is it possible to reference a function or access a var from script B in script A?

like in script A : var digit = 1
and script B : var seconddigit = scriptA.digit + 2

im not sure if that is the right way to do it.

So, all local variables like this can’t be accessed outside of that context/script:

var digit = 1;

To access a value from another script, add it as a property to this script:

MyScript.prototype.initialize = function(){
   this.digit = 1;

Now from your other script, you need first to grab a reference to the entity holding an instance of this script. Then you can access this value like this:

var scriptEntity ='myEntity');
1 Like

aahhhh. i get it now. thanks!!