# webcam view inverted

**URL:** https://discussions.unity.com/t/webcam-view-inverted/69331
**Category:** Questions & Answers
**Created:** [April 24, 2013, 10:32am UTC](https://discussions.unity.com/t/webcam-view-inverted/69331 "2013-04-24T10:32:49Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![tingwei](https://avatars.discourse-cdn.com/v4/letter/t/c6cbf5/32.png) [@tingwei](https://discussions.unity.com/u/tingwei)
#### Post date: [April 24, 2013, 10:32am UTC](https://discussions.unity.com/t/webcam-view-inverted/69331/1 "2013-04-24T10:32:49Z")

</div>

Hi,there!

I have some questions in unity3d use gyroscope and webcam to make argument reality!  
but when i build to android and start the app, my view is inverted to the left

my default orientation is “portrait”

and here are the scripts about gyroscope and webcam

**gyroscope script:**

```
using UnityEngine;
using System.Collections;

public class CameraGy : MonoBehaviour {

private bool gyroBool;
private Gyroscope gyro;
private Quaternion rotFix;

void Start()
{

var originalParent = transform.parent; // check if this transform has a parent
var camParent = new GameObject ("camParent"); // make a new parent
camParent.transform.position = transform.position; // move the new parent to this transform position
transform.parent = camParent.transform; // make this transform a child of the new parent
camParent.transform.parent = originalParent; // make the new parent a child of the original parent

gyroBool = Input.isGyroAvailable;

if (gyroBool) {

gyro = Input.gyro;
gyro.enabled = true;

if (Screen.orientation == ScreenOrientation.LandscapeLeft) {

camParent.transform.eulerAngles =new Vector3(90,90,0);
} 
else if (Screen.orientation == ScreenOrientation.Portrait) {
camParent.transform.eulerAngles =new Vector3(90,180,0);
}

if (Screen.orientation == ScreenOrientation.LandscapeLeft) {
rotFix =new Quaternion(0,0,0.7071F,0.7071F);
} 
else if (Screen.orientation == ScreenOrientation.Portrait) {
rotFix =new Quaternion(0,0,1,0);
}
//Screen.sleepTimeout = 0;
}
else
{
print("NO GYRO");
}

}
void Update ()
{
if (gyroBool)
{

Quaternion camRot = gyro.attitude * rotFix;
/*float tmp=camRot.x;
camRot.x=camRot.y;
camRot.y=tmp;*/
transform.localRotation = camRot;
}
GameObject.Find("x").guiText.text=gameObject.transform.rotation.x.ToString();
GameObject.Find("y").guiText.text=gameObject.transform.rotation.y.ToString();
GameObject.Find("z").guiText.text=gameObject.transform.rotation.y.ToString();
}

}

```

**webcam script:**

```
using UnityEngine;
using System.Collections;

public class WebCam : MonoBehaviour {
private WebCamTexture webCam; 
public GameObject background;

// Use this for initialization
void Start () {

webCam =new WebCamTexture(); 

renderer.material.mainTexture=webCam;

background.transform.localScale=new Vector3(1,1,1);
background.guiTexture.texture=webCam;
webCam.Play(); 

}

// Update is called once per frame
void Update () {

}
}

```

can anyone help me to fix my problem!!

thanks a lot and sorry for my bad English!!!

---

<div class="post-metadata">

### Author: ![Oak99](https://avatars.discourse-cdn.com/v4/letter/o/3bc359/32.png) [@Oak99](https://discussions.unity.com/u/Oak99)
#### Post date: [May 30, 2013, 3:58pm UTC](https://discussions.unity.com/t/webcam-view-inverted/69331/2 "2013-05-30T15:58:17Z")

</div>

Same here and I got no solution.

In landscape mode it can be solved using localScale in the guitexture but in portrait I don’t know how “rotate” the guitexture attach to the webcamTexture.

I followed this [http://jaymayblog.blogspot.com.es/2012/08/camera-feed-background-in-unity.html](http://jaymayblog.blogspot.com.es/2012/08/camera-feed-background-in-unity.html)

and works “well” but the video feed on the background is inverted, I don´t know how to solve and correct this.

```
...

bgimg = GameObject.Find ("BackGround Image");

cameras = WebCamTexture.devices;

camfeed = new WebCamTexture (cameras [0].name, Screen.width, Screen.height, 30);			

			
			if (Screen.orientation == ScreenOrientation.LandscapeRight) {
				bgimg.transform.localScale = new Vector3 (-0.02f, -0.02f, 0.02f);
				
				Debug.Log ("ORIENTATION - LANDSCAPERIGHT");
			}

           if (Screen.orientation == ScreenOrientation.Portrait) {

                   ......

        }

bgimg.guiTexture.texture = camfeed; camfeed.Play ();

```
