示例#1
0
    void Start()
    {
        if (!VrUtility.IsPicoVR)
        {
            return;
        }

        var ctlr = Controller;

        if (ctlr == null)
        {
            enabled = false;
        }
        controller      = ctlr;
        InitCullingMask = camera.cullingMask;
#if UNITY_EDITOR
        PicoVRManager.SDK.currentDevice.InitForEye(ref material);
        Setup();
#endif
#if ANDROID_DEVICE
        if (PicoVRManager.SDK.currentDevice.Async)
        {
            camera.enabled = true;
        }
#endif
    }
示例#2
0
    /// <summary>
    /// 设置相机参数
    /// Note :当且仅当 不存在camera时候才会调用
    /// </summary>
    /// <param name="controller"></param>
    /// <param name="parx"></param>
    /// <param name="pary"></param>
    public void CopyCameraAndMakeSideBySide(PicoVREyeManager controller,
                                            float parx, float pary)
    {
        // camera.CopyFrom(controller.GetComponent<Camera>());
        camera.cullingMask = InitCullingMask;
        Camera headCamera = controller.GetComponent <Camera>();

        camera.aspect      = headCamera.aspect;
        camera.rect        = headCamera.rect;
        camera.fieldOfView = headCamera.fieldOfView;
#if !ANDROID_DEVICE && !IOS_DEVICE
        float ipd = PicoVRManager.SDK.picoVRProfile.device.devLenses.separation * controller.stereoMultiplier;
        transform.localPosition = (eye == PicoVRManager.Eye.LeftEye ? -ipd / 2 : ipd / 2) * Vector3.right;
        transform.localRotation = Quaternion.identity;
        transform.localScale    = Vector3.one;
        Rect    rect   = camera.rect;
        Vector2 center = rect.center;
        center.x    = Mathf.Lerp(center.x, 0.5f, Mathf.Clamp01(controller.stereoPaddingX));
        center.y    = Mathf.Lerp(center.y, 0.5f, Mathf.Clamp01(controller.stereoPaddingY));
        rect.center = center;
        float width = Mathf.SmoothStep(-0.5f, 0.5f, (rect.width + 1) / 2);
        rect.x    += (rect.width - width) / 2;
        rect.width = width;
        rect.x    *= (0.5f - rect.width) / (1 - rect.width);
        if (eye == PicoVRManager.Eye.RightEye)
        {
            rect.x += 0.5f; // Move to right half of the screen.
        }
        float parallax = Mathf.Clamp01(controller.screenParallax);
        if (controller.GetComponent <Camera>().rect.width < 1 && parallax > 0)
        {
            rect.x -= parx / 4 * parallax; // Extra factor of 1/2 because of side-by-side stereo.
            rect.y -= pary / 2 * parallax;
        }
#endif
#if ANDROID_DEVICE || IOS_DEVICE
        Rect rect = new Rect(0, 0, 1, 1);
#endif
        camera.rect = rect;
    }