Esempio n. 1
0
    /// <summary>
    /// Corrects the screen ratio.
    /// </summary>
    void correctScreenRatio()
    {
        int videoWidth   = 640;
        int videoHeight  = 480;
        int ScreenWidth  = 640;
        int ScreenHeight = 480;

        float videoRatio  = 1;
        float screenRatio = 1;

        if (this.webcam != null)
        {
            videoWidth  = webcam.Width();
            videoHeight = webcam.Height();
        }

        videoRatio = videoWidth * 1.0f / videoHeight;
#if !UNITY_EDITOR && (UNITY_ANDROID || UNITY_IOS)
        ScreenWidth  = Mathf.Max(Screen.width, Screen.height);
        ScreenHeight = Mathf.Min(Screen.width, Screen.height);
#else
        ScreenWidth  = Screen.width;
        ScreenHeight = Screen.height;
#endif
        screenRatio = ScreenWidth * 1.0f / ScreenHeight;

        screenVideoRatio = screenRatio / videoRatio;
        isCorrected      = true;

        if (e_CameraPlaneObj != null)
        {
            e_CameraPlaneObj.GetComponent <CameraPlaneController>().correctPlaneScale(screenVideoRatio);
        }
    }
Esempio n. 2
0
    /// <summary>
    /// Corrects the screen ratio.
    /// </summary>
    private void correctScreenRatio()
    {
        int videoWidth   = 640;
        int videoHeight  = 480;
        int ScreenWidth  = 640;
        int ScreenHeight = 480;

        float videoRatio  = 1;
        float screenRatio = 1;

        if (this.webcam != null)
        {
            videoWidth  = webcam.Width();
            videoHeight = webcam.Height();
        }
        videoRatio   = videoWidth * 1.0f / videoHeight;
        ScreenWidth  = Mathf.Max(Screen.width, Screen.height);
        ScreenHeight = Mathf.Min(Screen.width, Screen.height);
        screenRatio  = ScreenWidth * 1.0f / ScreenHeight;

        screenVideoRatio = screenRatio / videoRatio;
        isCorrected      = true;

        if (e_CameraPlaneObj != null)
        {
            e_CameraPlaneObj.GetComponent <CameraPlaneController>().CorrectPlaneScale(screenVideoRatio);
        }
    }