Ejemplo n.º 1
0
    void CreateScreenCamera()
    {
        GameObject newCam = new GameObject();
        Camera     rsCam  = newCam.AddComponent <Camera>();

        meshCamera         = newCam.transform;
        rsCam.orthographic = true;
        if (android)
        {
            if (curPlatform == 1)
            {
                rsCam.orthographicSize = androidCalib.GetEyeCamSizeAndroid_S8();
            }
            else if (curPlatform == 2)
            {
                rsCam.orthographicSize = androidCalib.GetEyeCamSizeAndroid_Mate10_DW();
            }
            else if (curPlatform == 3)
            {
                rsCam.orthographicSize = androidCalib.GetEyeCamSizeAndroid_Mate10_PRO();
            }
        }

        else
        {
            rsCam.orthographicSize = pcPlugin.CamSize();
        }

        rsCam.nearClipPlane       = 0.0f;
        rsCam.farClipPlane        = 0.01f;
        rsCam.clearFlags          = CameraClearFlags.SolidColor;
        rsCam.backgroundColor     = Color.black;
        rsCam.useOcclusionCulling = false;
        meshCamera.transform.SetParent(meshCenter);

        if (this.leftEye)
        {
            if (this.android)
            {
                if (curPlatform == 1)
                {
                    rsCam.transform.localPosition = androidCalib.GetLeftEyeCamPosAndroid_S8();
                }
                else if (curPlatform == 2)
                {
                    rsCam.transform.localPosition = androidCalib.GetLeftEyeCamPosAndroid_Mate10_DW();
                }
                else if (curPlatform == 3)
                {
                    rsCam.transform.localPosition = androidCalib.GetLeftEyeCamPosAndroid_Mate10_PRO();
                }

                leftCamRot.eulerAngles = androidCalib.GetLeftEyeCamRotAndroid();
            }

            else

            {
                rsCam.transform.localPosition = pcPlugin.LeftCamPos();
                leftCamRot.eulerAngles        = pcPlugin.LeftCamRot();
            }

            rsCam.transform.localRotation = leftCamRot;
        }

        else if (!leftEye)
        {
            if (this.android)
            {
                if (curPlatform == 1)
                {
                    rsCam.transform.localPosition = androidCalib.GetRightEyeCamPosAndroid_S8();
                }
                else if (curPlatform == 2)
                {
                    rsCam.transform.localPosition = androidCalib.GetRightEyeCamPosAndroid_Mate10_DW();
                }
                else if (curPlatform == 3)
                {
                    rsCam.transform.localPosition = androidCalib.GetRightEyeCamPosAndroid_Mate10_PRO();
                }

                rightCamRot.eulerAngles = androidCalib.GetRightEyeCamRotAndroid();
            }

            else
            {
                rsCam.transform.localPosition = pcPlugin.RightCamPos();
                rightCamRot.eulerAngles       = pcPlugin.RightCamRot();
            }

            rsCam.transform.localRotation = rightCamRot;
        }

        if (this.leftEye)
        {
            meshCamera.name = "LeftEyeCam";

            if (android == false)
            {
                rsCam.rect = new Rect(0.0f, 0.0f, 0.5f, 1.0f);
            }
            else if (android == true)
            {
                rsCam.rect = new Rect(0.0f, 0.0f, 0.5f, 1.0f);
            }
        }

        else
        {
            meshCamera.name = "RightEyeCam";

            if (android == false)
            {
                rsCam.rect = new Rect(0.5f, 0.0f, 0.5f, 1.0f);
            }
            else if (android == true)
            {
                rsCam.rect = new Rect(0.5f, 0.0f, 0.5f, 1.0f);
            }
        }

        Graphics.DrawMeshNow(mesh, new Vector3(0, 0, 0), Quaternion.identity);
    }