DeviceOrientation.FaceDown to DeviceOrientation.Faceup

question, how do i change the DeviceOrientation.FaceDown to DeviceOrientation.Faceup i dont know how too declare it with and where too put in the script.

i tried making a c script and put DeviceOrientation.Faceup in the script but it gave
the error: unityengine.deviceorientation.FaceUp is a invalid but a type was expected

anyone so kind too help me out.

this is my script
using UnityEngine;
using UnityEngine;
using System.Collections;

public class rotate2 : MonoBehaviour {
	// initial camera and sensor value
	private Quaternion initialCameraRotation = Quaternion.identity;
	private bool gotFirstValue = false;

	float xRot, yRot, zRot;
	public float rotSpeed = 20f;

	void Update ()
			initialCameraRotation = Quaternion.Euler(0, 0, 0);
		// This tilts the axis of the camera like shaking a head yes
		xRot = Input.acceleration.y * 180f;
		// This tilts like a driving wheel to make it like shaking head no
		yRot = Input.acceleration.x * -180f;
		zRot = 0f;
		transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(new Vector3(xRot, yRot, zRot)), Time.deltaTime * rotSpeed);

First, I recommend that you go through all the Unity Scripting tutorials (Learn game development w/ Unity | Courses & tutorials in game design, VR, AR, & Real-time 3D | Unity Learn), specifically the enumeration tutorial (

Second, it sounds like you want to set the screen orientation. The device orientation is the physical orientation of the device. Since Unity cannot (normally) change the physical orientation of the device, the device orientation is read only, i.e.


The screen orientation on the other hand changes the orientation of the screen as displayed by the software and can be set (as well as read).

Screen.orientation = ScreenOrientation.LandscapeLeft

In addition, you can set the screen to automatically rotate but disable some of the rotations,

Screen.orientation = ScreenOrientation.AutoRotation;

Finally, I would like to add that if you want to set the default values for the screen orientation, you can do so without scripts. You will find it at Edit->ProjectSettings->Player under Resolution and Presentation.