Author Topic: UITexture feed with video does not work anymore  (Read 2503 times)

MartinG

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
UITexture feed with video does not work anymore
« on: July 04, 2014, 04:35:16 AM »
Hello,

we make an AR App, in which the user can watch videos in 3D Space (that works) and in a 2D menu, which is built with NGUI. A UITexture shows a Preview Image in the NGUI videoplayerwindow. That works. But changing to play mode, the UITexture doesn´t show the video anymore. It worked with NGUI 3.5.3 and older. But with the current 3.6.6 it doesn´t work. It has nothing to do with the texture UVs, I checked this. It seems more to be, as if there is only 1 pixel of the video is displayed all the time. Streched to the UITexture. If I change the UI Texture back to a normal texture (Preview Image), all is good. Playing video again, it´s broken.
Changing the project back to NGUI 3.5.3, all is fine again, also with video.

For more information, we use the VideoPlayer of the AR Vuforia PlugIn.

In Code it is so, that the videoplayer gets the texture ID of the texture it should draw the videoframes to.

And on play/pause/stop/errors and so on, the texture is switched between the video and the preview/error image.

The videoplayer gets the texture to draw to:

 int nativeTextureID = mVideoTexture.GetNativeTextureID();
bool textureSetToVideoPlayer = mVideoPlayer.SetVideoTextureID(nativeTextureID);

the videoplayer is set to different states:

if (newState == KIDSVideoPlayerHelper.MediaState.PLAYING ||  newState == KIDSVideoPlayerHelper.MediaState.PAUSED)
        {
         uiTexture.mainTexture = mVideoTexture;
              uiTexture.uvRect = new Rect(0f,1f,1f,-1f); //setting UV to this values, because the videoplayer delivers the video "flipped"
        }
        else
        {
       if (mKeyframeTexture != null)
            {
   
                uiTexture.mainTexture = mKeyframeTexture;
                uiTexture.uvRect = new Rect(0f,0f,1f,1f); //setting UV back to normal values

            }
        }

The "flipping" of UVs is a must, it works in NGUI 3.5.3 and older, and on Planes/Quads (NON NGUI Objects) the UVs for videoplaying must also be set in a special way.

May be you can´t do anything about this, because it seems to be a problem between the interaction of to PlugIns. And NGUI is for Unity and not for Vuforia. But may be you have an idea, what could be the problem with the new NGUI UITexture. The only change since 3.5.3 i found was UITexture can now be set up like UISprites.

Greetings,

Martin

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITexture feed with video does not work anymore
« Reply #1 on: July 04, 2014, 02:29:31 PM »
To flip the texture in NGUI, you can use the "Flip" option on the widget itself. Don't mess with the UV rect.