Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Device Camera is rotated in Portrait Orientation

Discussion in 'iOS and tvOS' started by rmeas, Apr 30, 2014.

  1. rmeas

    rmeas

    Joined:
    Mar 11, 2014
    Posts:
    6
    I setup the ios camera to serve as the background for a scene following the procedure here.

    It works fine when iOS and the Scene are set to Landscape orientation, but when they are set to portrait orientation, the camera feed displays rotated counter clockwise 90 degrees.

    Any ideas?
     
  2. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,600
  3. rmeas

    rmeas

    Joined:
    Mar 11, 2014
    Posts:
    6
    In the procedure, you adding it straight a GuiTexture on a separate background layer. This is convenient because you can set the pixelInset to be equal to the Screen.height / Screen.width such that your video always scales to the resolution of your screen.

    As I understand, GuiTextures on their own cannot be rotated, so I'm not sure how videoRotationAngle could be used in conjunction.

    Is there a way to do this or is it necessary to apply the webcam texture to a gameobject such that it can be rotated (oriented) appropriately?
     
  4. Hitori

    Hitori

    Joined:
    Jun 1, 2014
    Posts:
    2
    hello, have you fix this already?..
    cause i'm dying finding the solution to it -_-
    please help .. T_T
     
  5. Smilediver

    Smilediver

    Joined:
    May 5, 2011
    Posts:
    72
  6. Maisey

    Maisey

    Joined:
    Feb 17, 2014
    Posts:
    300
    Any valid solution for a plain Texture?
     
  7. alvaro-em

    alvaro-em

    Joined:
    Feb 23, 2012
    Posts:
    77
    I have been playing around with this for some hours, and the recommended links are not useful when autorotation is set to true. Although WebcamTexture.videoRotationAngle is returning the right value, I can't see how to apply to the rawImage, since it gets rotated together with the whole interface. Let's say our webcamTexture has a landscape resolution of 640 x 480. The problem here is that when the device rotation is set to portrait, the webcamTexture resolution should change to 480 x 640 as Screen.width and Screen.height are, but it actually doesn't, so the image gets stretched.

    The only thing that would have it working properly would be to get the rawImage "out" of the autorotation behaviour and change its rotation manually according to the WebcamTexture.videoRotationAngle value, but I couldn't find any way to apply these guesses to my case.

    Did anyone find a solution to this problem?
     
  8. domdev

    domdev

    Joined:
    Feb 2, 2015
    Posts:
    375
    its 2019, but I'm still looking for this solution? any?
     
  9. MaryamKamel

    MaryamKamel

    Joined:
    Feb 5, 2016
    Posts:
    22
    u would need to rotate the object you r on which the review of your camera is displayed ,
    for me i used a raw image and here is my solution,
    Code (CSharp):
    1.    orient = -selectedCamTexture.videoRotationAngle;
    2.         CamFeed.rectTransform.localEulerAngles = new Vector3(0, 0, orient);