I am following Vidoe Playback Sample in Unity3d, I just want to applied my texture instead of using default icon of Play Pause and error while video ready loading and when error occur. I successfully set my icons(in .jpg format), but it distrub the ratio(width/height) of images when rendering. So i want to apply "ScaleMode.ScaleToFit" property in icon textures so that it maintain the ration of images and not strech my images, but don't know how to do this.
"Texture2D tex = Resources.Load("ImageTargetTextures/WhatTheBuck/MyImage") as Texture2D;
video.m_playTexture = tex;
video.m_busyTexture = tex;
video.m_errorTexture = tex;
video.mIconPlane.renderer.material.mainTexture = tex;
video.mIconPlane.transform.rotation=Quaternion.AngleAxis(180, Vector3.up);
video.VideoPlayer.Pause();"
Here is how i am rendering my images when specific marker detects it render successfully but strech my images. Kindly help me on that. Thanks in advance
This what Nalin is referring to, at line 399 in VideoPlaybackBehaviour.cs
private void ScaleIcon()
{
// Icon should fill 50% of the narrowest side of the video
float videoWidth = Mathf.Abs(transform.localScale.x);
float videoHeight = Mathf.Abs(transform.localScale.z);
float iconWidth, iconHeight;
if (videoWidth > videoHeight)
{
iconWidth = 0.5f * videoHeight / videoWidth;
iconHeight = 0.5f;
}
else
{
iconWidth = 0.5f;
iconHeight = 0.5f * videoWidth / videoHeight;
}
mIconPlane.transform.localScale = new Vector3(-iconWidth, 1.0f, iconHeight);
}