- Home /
How to show portions of a video in many different target textures
I've an MP4 video and to play it, I've created a RawImage with a texture and assigned the same texture to the VideoPlayer's target texture. So far so good and my video plays as expected.
The next challenge is to split the video into a 3x3 grid and show different portions of the video in each element of the grid. I guess I need to create 9 RawImage objects with the same texture I mentioned above and set the portion of the video to render... Am I right? How do I redirect the VideoPlayer output to those RawImage objects efficiently?
Many thanks.
Answer by Namey5 · Mar 06, 2021 at 10:00 AM
Seeing as this is using the UGUI system, you should be able to just use the one texture in combination with an image mask to only show particular sections in each instance;
https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/script-Mask.html
Imagine we have a raw image with dimensions of 300x300.
If we add it as a child of a mask with dimensions of 100x100, we get just a single tile that can be moved around freely.
If we were to then reposition the child (raw image) within the mask, we can get the mask to cover different areas.
Make 9 copies and put them all together and you get a complete image made up of entirely separate tiles.
Thank you very much, but I understand right, the video behind the mask objects is still visible. Instead, only the video portions in the 3x3 grid should be visible. Furthermore, one of the 9 grid elements shall be free to let the user move the tiles horizontally or vertically. Perhaps I'm missing something.
I'm not entirely sure what you mean - if the display is a child of the mask then the portions of the video outside the mask will not be visible. If you could provide an image/mock-up of what you are trying to achieve it would probably help a lot more.
is a screenshot of what I'm trying to do. You can see a video running in the middle of the mobile device... and I'm trying to split it in 9 square tiles (3x3 matrix) and scramble them in random order while keeping the video playing. That's it :-)
Thank u very much for your great support, as a newbie I really appreciate it :-)
Your answer
Follow this Question
Related Questions
Unity 1080p Video player 1 Answer
Changing from static texture to video texture & play video? 0 Answers
Video texture problem? 2 Answers
Play, seek a video 1 Answer
Spritesheet vs Video 1 Answer