本文整理汇总了C#中ScreenOrientation类的典型用法代码示例。如果您正苦于以下问题:C# ScreenOrientation类的具体用法?C# ScreenOrientation怎么用?C# ScreenOrientation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScreenOrientation类属于命名空间,在下文中一共展示了ScreenOrientation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ScreenUtils
private ScreenUtils(int width, int height)
{
this.orientation = ScreenOrientation.Portrait;
this.width = width;
this.height = height;
this.max_width = (width > height) ? width : height;
}
示例2: RevMobIosBanner
public RevMobIosBanner(string placementId, ScreenOrientation[] orientations, float x, float y, float width, float height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.orientations = orientations;
this.placementId = placementId;
}
示例3: getOrthographicSize
/// <summary>
/// Determine size of the orthographic camera based on screen orientation.
/// </summary>
/// <returns>
/// The orthographic camera size.
/// </returns>
/// <param name='orientation'>
/// Screen orientation
/// </param>
private static float getOrthographicSize(ScreenOrientation orientation)
{
if (orientation == ScreenOrientation.Portrait || orientation == ScreenOrientation.PortraitUpsideDown)
return 1.0f;
if (Screen.width < Screen.height)
return ((float)Screen.width)/((float)Screen.height);
else
return ((float)Screen.height)/((float)Screen.width);
}
示例4: OrientationChanged
void OrientationChanged(ScreenOrientation newOrientation)
{
// Debug.LogWarning("new orientation: " + newOrientation + " material: " + materialIndex);
if (newOrientation == ScreenOrientation.Landscape) {
ChangeMaterial(materialLandscape, materialIndex);
}
else if (newOrientation == ScreenOrientation.Portrait) {
ChangeMaterial(materialPortrait, materialIndex);
}
}
示例5: ActionOnOrientationChanged
public void ActionOnOrientationChanged(ScreenOrientation newOrientation)
{
if(newOrientation == ScreenOrientation.Landscape)
{
transform.localPosition = positionLandscape;
}
else
{
transform.localPosition = positionPortrait;
}
}
示例6:
public MenüSate(StateManager managerRef) // Constructor
{
#if UNITY_ANDROID || UNITY_IPHONE
Screen.orientation = ScreenOrientation.AutoRotation;
saveOri = Screen.orientation;
#endif
manager = managerRef;
Application.LoadLevel ("Menue");
}
示例7: UpdateScale
void UpdateScale(ScreenOrientation orientation)
{
if (screenWidth == Mathf.Max(Screen.width, Screen.height)) {
return;
}
screenWidth = Mathf.Max(Screen.width, Screen.height);
float myScaleFactor = screenWidth / referenceWidth;
cachedTransform.localScale = originalScale * Mathf.Clamp(dpiScaleFactor / myScaleFactor, minScaleFactor, maxScaleFactor);
//Debug.LogWarning("New Scale: " + dpiScaleFactor / myScaleFactor);
}
示例8: SetRect
public void SetRect(Rect screenRect, Rect rect, Rect landscapeRect, ScreenOrientation orientation) {
this.screenRect = screenRect;
this.rect = rect;
this.orientation = orientation;
this.sprite = Resources.Load<Sprite>("UI.Windows/DevicePreview/Images/" + this.GetMainImage());
if (this.sprite != null) {
/*
if (orientation == ScreenOrientation.Landscape) {
var textureWidth = this.sprite.texture.width;
var textureHeight = this.sprite.texture.height;
var border = this.sprite.border;
var offsetRect = new Vector4(border.x / textureWidth * this.rect.width, border.y / textureHeight * this.rect.height, border.z / textureWidth * this.rect.width, border.w / textureHeight * this.rect.height);
this.landscapeRect = new Rect(this.rect.x - offsetRect.x + offsetRect.z * 0.5f,
this.rect.y - offsetRect.y + offsetRect.w * 0.5f,
this.rect.width + offsetRect.z * 0.5f + offsetRect.z,
this.rect.height + offsetRect.w * 0.5f + offsetRect.w);
} else {
this.landscapeRect = landscapeRect;
}*/
if (orientation == ScreenOrientation.Landscape) {
var offsetRect = this.sprite.border;
this.deviceRect = new Rect(this.rect.x - offsetRect.x + offsetRect.z * 0.5f,
this.rect.y - offsetRect.y + offsetRect.w * 0.5f,
this.rect.width + offsetRect.z * 0.5f + offsetRect.z,
this.rect.height + offsetRect.w * 0.5f + offsetRect.w);
} else {
this.rect = landscapeRect;
var offsetRect = this.sprite.border;
this.deviceRect = new Rect(this.rect.x - offsetRect.x + offsetRect.z * 0.5f,
this.rect.y - offsetRect.y + offsetRect.w * 0.5f,
this.rect.width + offsetRect.z * 0.5f + offsetRect.z,
this.rect.height + offsetRect.w * 0.5f + offsetRect.w
);
}
}
}
示例9: Awake
// Use this for initialization
void Awake () {
float Screenheight = (float)_targetCam.orthographicSize* 2.0f;
float Screenwidth = Screenheight * Screen.width / Screen.height;
height = Screenheight ;
width = Screenwidth;
this.transform.localPosition = new Vector3(0,0,-0.8f);
#if UNITY_EDITOR
transform.localEulerAngles = new Vector3(90,180,0);
transform.localScale = new Vector3(width/10, 1.0f, height/10);
#elif UNITY_WEBPLAYER
transform.localEulerAngles = new Vector3(90,180,0);
transform.localScale = new Vector3(width/10, 1.0f, height/10);
#endif
orientation = Screen.orientation;
Screen.sleepTimeout = SleepTimeout.NeverSleep;
if (Screen.orientation == ScreenOrientation.Portrait||
Screen.orientation == ScreenOrientation.PortraitUpsideDown) {
#if UNITY_ANDROID
transform.localEulerAngles = new Vector3(0,270,90);
transform.localScale = new Vector3(height/10, 1.0f, width/10);
#elif UNITY_IOS
if( Screen.orientation == ScreenOrientation.PortraitUpsideDown)
{
transform.localEulerAngles = new Vector3(0,270,90);
}
else
{
transform.localEulerAngles = new Vector3(0,90,270);
}
transform.localScale = new Vector3(-1*height/10, 1.0f, width/10);
#endif
} else if (Screen.orientation == ScreenOrientation.Landscape) {
#if UNITY_ANDROID
transform.localEulerAngles = new Vector3(90,180,0);
transform.localScale = new Vector3(width/10, 1.0f, height/10);
#elif UNITY_IOS
transform.localEulerAngles = new Vector3(-90,0,0);
transform.localScale = new Vector3(-1*width/10, 1.0f, height/10);
#endif
}
}
示例10: SetResolution
public bool SetResolution(int width, int height, float ppi, ScreenOrientation orientation, IDeviceOutput deviceOutput) {
var result = false;
this.orientation = orientation;
this.deviceOutput = deviceOutput;
this.ppi = ppi;
this.currentWidth = width;
this.currentHeight = height;
this.tempScreenshot = new Texture2D(width, height, TextureFormat.RGB24, false);
this.tempRenderTexture = new RenderTexture(width, height, 24, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default);
/*
if (this.previewCamera == null) {
var go = new GameObject("__TempCamera");
this.previewCamera = go.AddComponent<DevicePreviewCamera>();
}
this.previewCamera.Initialize(this.tempRenderTexture, () => {
this.root.Repaint();
GameObject.DestroyImmediate(this.previewCamera.gameObject);
});*/
var size = new Vector2(this.width, this.height);
var imageSize = new Vector2(this.currentWidth, this.currentHeight);
var factor = this.GetFactor(imageSize, size);
var k = Screen.dpi / this.ppi;
if (factor / k < 1f) {
result = true;
}
this.isActive = true;
this.Update();
return result;
}
示例11: GetProjectionGL
// Returns the QCAR projection matrix
public static Matrix4x4 GetProjectionGL(float nearPlane, float farPlane, ScreenOrientation screenOrientation)
{
float[] projMatrixArray = new float[16];
IntPtr projMatrixPtr = Marshal.AllocHGlobal(
Marshal.SizeOf(typeof(float)) * projMatrixArray.Length);
QCARWrapper.Instance.GetProjectionGL(nearPlane, farPlane, projMatrixPtr,
(int)screenOrientation);
Marshal.Copy(projMatrixPtr, projMatrixArray, 0, projMatrixArray.Length);
Matrix4x4 projMatrix = Matrix4x4.identity;
for (int i = 0; i < 16; i++)
projMatrix[i] = projMatrixArray[i];
Marshal.FreeHGlobal(projMatrixPtr);
return projMatrix;
}
示例12: ResetOrientation
/// <summary>
/// Method to approraitiatly rotate the device and screen orientation
/// </summary>
private void ResetOrientation()
{
Vector3 cardboardRot = Cardboard.SDK.transform.GetChild (0).rotation.eulerAngles;
if ( (cardboardRot.z + ScreenRotationThreshold > 360f) || (0f > cardboardRot.z - ScreenRotationThreshold) ) {
currOrient = ScreenOrientation.LandscapeLeft;
} else if ( (cardboardRot.z - ScreenRotationThreshold < 270f) && (270f < cardboardRot.z + ScreenRotationThreshold) ) {
currOrient = ScreenOrientation.Portrait;
} else if ( (cardboardRot.z - ScreenRotationThreshold < 90f) && (90f < cardboardRot.z + ScreenRotationThreshold) ) {
currOrient = ScreenOrientation.PortraitUpsideDown;
} else if ( (cardboardRot.z - ScreenRotationThreshold < 180f) && (180f < cardboardRot.z + ScreenRotationThreshold) ) {
currOrient = ScreenOrientation.LandscapeRight;
}
if (NaviMobileManager.Instance.canUserResetOrientation)
Screen.orientation = currOrient;
NaviMobileManager.Instance.SendCurrentSize ();
}
示例13: SetRect
public void SetRect(Rect groupRect, Rect screenRect, Rect rect, Rect landscapeRect, ScreenOrientation orientation) {
this.groupRect = groupRect;
this.screenRect = screenRect;
this.rect = rect;
this.orientation = orientation;
if (this.sprite == null) {
var filepath = "UI.Windows/DevicePreview/Images/" + this.GetMainImage();
this.sprite = UnityEditor.UI.Windows.CoreUtilities.Load<Sprite>(filepath);
}
if (this.sprite != null) {
var imageSize = this.sprite.rect.size;
var offsetRect = this.sprite.border;
var offset = this.GetOffset();
var cx = (imageSize.x - offsetRect.x - offsetRect.z) * 0.5f + offsetRect.x + offset.x;
var cy = (imageSize.y - offsetRect.y - offsetRect.w) * 0.5f + offsetRect.y + offset.y;
offset = new Vector2((cx - imageSize.x * 0.5f) * 0.5f, (imageSize.y * 0.5f - cy) * 0.5f);
this.rect.center -= offset;
if (orientation == ScreenOrientation.Portrait) {
var imageContentRect = new Rect(offsetRect.x, offsetRect.y, imageSize.x - offsetRect.z - offsetRect.x, imageSize.y - offsetRect.w - offsetRect.y);
var k = this.rect.height / imageContentRect.height;
this.deviceRect = new Rect(this.groupRect.x + this.rect.center.x - imageSize.x * 0.5f * k, this.groupRect.y + this.rect.center.y - imageSize.y * 0.5f * k, imageSize.x * k, imageSize.y * k);
} else {
var imageContentRect = new Rect(offsetRect.y, offsetRect.x, imageSize.y - offsetRect.w - offsetRect.y, imageSize.x - offsetRect.z - offsetRect.x);
var k = this.rect.width / imageContentRect.width;
this.deviceRect = new Rect(this.groupRect.y + this.rect.center.x - imageSize.x * 0.5f * k, -this.groupRect.x + this.rect.center.y - imageSize.y * 0.5f * k, imageSize.x * k, imageSize.y * k);
}
}
}
示例14: Update
// Process the camera image and tracking data for this frame
public void Update(ScreenOrientation counterRotation)
{
// enable "fake tracking" if running in the free editor version
// that does not support native plugins
if (!QCARRuntimeUtilities.IsQCAREnabled())
{
UpdateTrackablesEditor();
return;
}
// Prepare the camera image container
UpdateImageContainer();
if (QCARRuntimeUtilities.IsPlayMode())
{
CameraDeviceImpl cameraDeviceImpl = (CameraDeviceImpl)CameraDevice.Instance;
if (cameraDeviceImpl.WebCam.DidUpdateThisFrame)
{
InjectCameraFrame();
}
}
// Draw the video background or update the video texture
// Also retrieve registered camera images for this frame
QCARWrapper.Instance.UpdateQCAR(mImageHeaderData, mNumImageHeaders,
mDrawVideobackground ? 0 : 1,
mLastProcessedFrameStatePtr, (int)counterRotation);
FrameState frameState = (FrameState)Marshal.PtrToStructure(mLastProcessedFrameStatePtr, typeof(FrameState));
// Reinitialize the trackable data container if required:
InitializeTrackableContainer(frameState.numTrackableResults);
// Handle the camera image data
UpdateCameraFrame();
// Handle the trackable data
UpdateTrackers(frameState);
if (QCARRuntimeUtilities.IsPlayMode())
{
// read out the index of the last processed frame
CameraDeviceImpl cameraDeviceImpl = (CameraDeviceImpl)CameraDevice.Instance;
cameraDeviceImpl.WebCam.SetFrameIndex(frameState.frameIndex);
}
}
示例15: SetOrientation
public static void SetOrientation(this IWebDriver driver, ScreenOrientation orientation)
{
((IRotatable) driver).Orientation = orientation;
}