void UpdateCamera() { // enable the camera, update its rect and replace its default projection matrix int width = 1920; int height = 1080; unsafe { int *widthPtr = &width, heightPtr = &height; SDPlugin.SixDegreesSDK_GetBackgroundTextureSize(widthPtr, heightPtr); } mCamera.rect = SDCameraUtils.GetCameraRect(width, height); mCamera.projectionMatrix = SDCameraUtils.GetProjectionMatrix(); mScreenOrientation = Screen.orientation; }
void Awake() { mCamera = GetComponent <Camera>(); if (!mCamera) { Debug.LogWarning("SDCamera must be attached to a camera object!"); return; } mScreenOrientation = ScreenOrientation.AutoRotation; mCamera.rect = SDCameraUtils.GetCameraRect(1920, 1080); mCamera.enabled = false; mPoseBuffer[0] = 1; mPoseBuffer[5] = 1; mPoseBuffer[10] = 1; mPoseBuffer[15] = 1; }
void Awake() { mCamera = GetComponent <Camera>(); if (!mCamera) { Debug.LogWarning("SDBackcam must be attached to a camera object!"); return; } if (!background) { Debug.LogWarning("SDBackcam must have a background RawImage!"); mCamera.enabled = false; return; } SDCameraUtils.Mode = cameraMode; mCamera.rect = SDCameraUtils.GetCameraRect(1920, 1080); mOrientation = ScreenOrientation.AutoRotation; }
void UpdateAspectRatio() { mOrientation = Screen.orientation; int width = mBackgroundTexture.width; int height = mBackgroundTexture.height; Vector2 pixelSize = SDCameraUtils.GetPixelCameraRect(width, height).size; Vector2 rotatedPixelSize = new Vector2(pixelSize.y, pixelSize.x); // for portrait mode mCamera.rect = SDCameraUtils.GetCameraRect(width, height); background.uvRect = new Rect(0f, 1f, 1f, -1f); switch (mOrientation) { case ScreenOrientation.LandscapeRight: background.rectTransform.sizeDelta = pixelSize; background.rectTransform.localRotation = Quaternion.Euler(0f, 0f, 180f); break; case ScreenOrientation.Portrait: background.rectTransform.sizeDelta = rotatedPixelSize; background.rectTransform.localRotation = Quaternion.Euler(0f, 0f, -90f); break; case ScreenOrientation.PortraitUpsideDown: background.rectTransform.sizeDelta = rotatedPixelSize; background.rectTransform.localRotation = Quaternion.Euler(0f, 0f, 90f); break; default: case ScreenOrientation.LandscapeLeft: background.rectTransform.sizeDelta = pixelSize; background.rectTransform.localRotation = Quaternion.Euler(0f, 0f, 0f); break; } }