Search Unity

Question Video should fit-inside but is offset after previously turning on VR mode

Discussion in 'Audio & Video' started by yoxallj, May 20, 2020.

  1. yoxallj

    yoxallj

    Joined:
    Dec 7, 2019
    Posts:
    3
    Hi,

    I have an app which displays videos in either 2D or 3D.

    There is a separate video player for 2D and 3D. The 2D video player has aspect set to "fit inside". This works exactly as expected unless the user has previously viewed a 3D video and VR mode has been turned on (and off again). Form this point onwards all 2D videos are offset from center in both portrait and landscape. In portrait mode the left side is now cropped, and in landscape mode the video is now left-justified with a black bar on the right.

    The Unity documentation for aspect describes it fitting relative to a "destination rectangle". Can I query this rectangle to see if it is changing, and maybe set it back to what it was after exiting VR mode.

    Or is there another solution?
     
  2. DominiqueLrx

    DominiqueLrx

    Unity Technologies

    Joined:
    Dec 14, 2016
    Posts:
    260
    Hi!

    Assuming that in your scenario the VideoPlayer is rendering into a Camera's near or far plane, one of two things are happening:
    • If the camera has a target texture set, then the destination rectangle will be the size of this texture.
    • Otherwise, the VideoPlayer will use Camera.pixelRect.
    Please let us know if you can find a workaround, but what you are describing is clearly a bug so it'd be nice if you could report it.

    Hope this helps,

    Dominique Leroux
    A/V developer at Unity
     
  3. yoxallj

    yoxallj

    Joined:
    Dec 7, 2019
    Posts:
    3
    Thank for the info.

    The camera is near plane. Using the info you gave me I can see that indeed after the playing the VR video the pixelRect has changed from (x:0.00, y:0.00, width:1280.00, height:720.00) beforehand, to (x:0.00, y:0.00, width:616.00, height:757.00).

    I am trying to reset it explicitly as a workaround, but when I execute the line
    Code (CSharp):
    1.         _videoCamera.pixelRect = new  Rect(0, 0, 1280,  720);
    2.  
    and then read it again immediately afterwards it is now (x:0.00, y:0.00, width:616.00, height:720.00), so the height has taken affect but not the width. I have also tried this waiting till the next frame between steps.

    I will try to recreate the original issue in a simplified app and report it as a bug.
     
  4. yoxallj

    yoxallj

    Joined:
    Dec 7, 2019
    Posts:
    3
    As an update, I have worked around the issue by using different cameras.
     
  5. DominiqueLrx

    DominiqueLrx

    Unity Technologies

    Joined:
    Dec 14, 2016
    Posts:
    260
    Hi!

    Thanks for the update and for submitting a bug. And glad you could find a workaround!

    If you have a chance, please post the bug id in here so I can go and help with the analysis.

    Dominique