public virtual void OnPreviewStart() { //Set the RawImage texture once the preview starts if (RawImage != null) { RawImage.texture = NatCam.Preview; } //Log else { Ext.Warn("Unitygram: Preview RawImage has not been set"); } //Log Ext.LogVerbose("Unitygram: Preview resolution: " + NatCam.ActiveCamera.ActiveResolution); }
Vector2 Regularize(Texture tex) { Vector2 input = new Vector2(tex.width, tex.height); bool isPortrait = Screen.orientation == ScreenOrientation.Portrait || Screen.orientation == ScreenOrientation.PortraitUpsideDown || (Screen.orientation == ScreenOrientation.AutoRotation && (Input.deviceOrientation == DeviceOrientation.Portrait || Input.deviceOrientation == DeviceOrientation.PortraitUpsideDown)); //This is the only appropriate flag int min = Mathf.RoundToInt(Mathf.Min(input.x, input.y)), max = Mathf.RoundToInt(Mathf.Max(input.x, input.y)); Ext.LogVerbose("PreviewScaler: orientation-" + Screen.orientation + " portrait-" + isPortrait + " min-" + min + " max-" + max); return(new Vector2 { x = isPortrait ? min : max, y = isPortrait ? max : min }); }