As MovieTexture has been deprecated after Unity 5.6.0b1, I am using VideoPlayer Api to play video over RawImage for Android, by taking reference from here. I am trying to add a toggle to switch from initial size of video played over RawImage Texture to full screen and back to original after video stops.
I have a perfectly playing video, and so far I am able to change the transform of the video to stretch to full screen with this code.
void Update () {
if (Input.GetButtonDown(“Jump”))
{
image.rectTransform.offsetMax = Vector2.Lerp(Vector2.up, Vector2.down, 100);
image.rectTransform.offsetMin = Vector2.Lerp(Vector2.left, Vector2.right, 100);
image.rectTransform.rotation = Quaternion.AngleAxis(Mathf.Lerp(0f, 90f, 50), Vector3.forward);
}
}
First two line inside the if block is able to full screen the RawImage on which the video is played effect shown in section 2 of image. Here’s the docs for Vector2.
For the third line code of rotation, I took reference from this discussion on Unity Forum, but still I am not getting the effect as I wanted, result in section 3. I wanted to rotate the content of the RawImage, but I am rotating the RawImage itself, it might be because the reference is not describing to rotate the content.
Can any one help me find out how can I solve it. If it helps version of Unity I am using is Unity 5.6.0b11 Beta, and download the sample project if you want to test in on your device. Unity Video Player.zip 18.33MB You can also follow this Video Tutorial on new VideoPlayer from YouTube.
Update 1
So far, the only thing I got is, I tried only with the rotation code and by removing first two lines inside if block, I was able to rotate the video, but when I try to stretch the RawImage, it is streching outside of the screen. See here



