Ejemplo n.º 1
0
 void Update()
 {
     if (!isStart)
     {
         return;
     }
     if (plane != null)
     {
         int cropleft, cropright, croptop, cropbottom, width, height;
         video.GetVideoCropValues(out cropleft, out cropright, out croptop, out cropbottom, out width, out height);
         float scalex = 1.0f;
         float scaley = 1.0f;
         float offx   = 0.0f;
         float offy   = 0.0f;
         if ((width > 0) && (height > 0))
         {
             int fullwidth = width + cropleft + cropright;
             scalex = (float)width / (float)fullwidth;
             offx   = (float)cropleft / (float)fullwidth;
             int fullheight = height + croptop + cropbottom;
             scaley = (float)height / (float)fullheight;
             offy   = (float)croptop / (float)fullheight;
         }
         plane.material.SetVector("_MainTex_ST", new Vector4(scalex, scaley * -1, offx, 1 - offy)); // typically we want to invert the Y on the video because thats how planes UV's are layed out
     }
 }