2 s164828378 s164828378 于 2016.03.30 17:35 提问

急!unity导入vuforia包后出现CS1061错误,求大神帮忙看看!

Assets/Vuforia/Scripts/Utilities/VRIntegrationHelper.cs(94,43): error CS1061: Type object' does not contain a definition forApplyCorrectedProjectionMatrix' and no extension method ApplyCorrectedProjectionMatrix' of typeobject' could be found (are you missing a using directive or an assembly reference?)

3个回答

caozhy
caozhy   Ds   Rxr 2016.03.30 23:07

贴出你的代码,很可能是你忘记调用方法加上括号了,方法名写错了,或者你的类型用错了。

s164828378
s164828378 已贴代码。。求大神帮忙
一年多之前 回复
s164828378
s164828378   2016.03.31 21:53

using System;
using UnityEngine;

using Vuforia;

public class VRIntegrationHelper : MonoBehaviour
{
private static Matrix4x4 mLeftCameraMatrixOriginal;
private static Matrix4x4 mRightCameraMatrixOriginal;

private static Camera mLeftCamera;
private static Camera mRightCamera;

private static HideExcessAreaAbstractBehaviour mLeftExcessAreaBehaviour;
private static HideExcessAreaAbstractBehaviour mRightExcessAreaBehaviour;

private static Rect mLeftCameraPixelRect;
private static Rect mRightCameraPixelRect;

private static bool mLeftCameraDataAcquired = false;
private static bool mRightCameraDataAcquired = false;

public bool IsLeft;
public Transform TrackableParent;

void Awake()
{
    GetComponent<Camera>().fieldOfView = 90f;
}

void Start()
{
    VuforiaBehaviour.Instance.RegisterVuforiaStartedCallback(OnVuforiaStarted);//报错
}

void OnVuforiaStarted()
{
    mLeftCamera = DigitalEyewearBehaviour.Instance.PrimaryCamera;
    mRightCamera = DigitalEyewearBehaviour.Instance.SecondaryCamera;

    mLeftExcessAreaBehaviour = mLeftCamera.GetComponent<HideExcessAreaAbstractBehaviour>();
    mRightExcessAreaBehaviour = mRightCamera.GetComponent<HideExcessAreaAbstractBehaviour>();
}

void LateUpdate()
{
    // to this only once per frame, not for both cameras
    if (IsLeft)
    {
        if (mLeftCameraDataAcquired && mRightCameraDataAcquired)
        {
            // make sure the central anchor point is set to the latest head tracking pose:
            DigitalEyewearBehaviour.Instance.CentralAnchorPoint.localRotation = mLeftCamera.transform.localRotation;
            DigitalEyewearBehaviour.Instance.CentralAnchorPoint.localPosition = mLeftCamera.transform.localPosition;

            // temporarily set the primary and secondary cameras to their offset position and set the pixelrect they will have for rendering
            Vector3 localPosLeftCam = mLeftCamera.transform.localPosition;
            Rect leftCamPixelRect = mLeftCamera.pixelRect;
            Vector3 leftCamOffset = mLeftCamera.transform.right.normalized * mLeftCamera.stereoSeparation * -0.5f;
            mLeftCamera.transform.position = mLeftCamera.transform.position + leftCamOffset;
            mLeftCamera.pixelRect = mLeftCameraPixelRect;

            Vector3 localPosRightCam = mRightCamera.transform.localPosition;
            Rect rightCamPixelRect = mRightCamera.pixelRect;
            Vector3 rightCamOffset = mRightCamera.transform.right.normalized * mRightCamera.stereoSeparation * 0.5f;
            mRightCamera.transform.position = mRightCamera.transform.position + rightCamOffset;
            mRightCamera.pixelRect = mRightCameraPixelRect;

            BackgroundPlaneBehaviour bgPlane = mLeftCamera.GetComponentInChildren<BackgroundPlaneBehaviour>();
            bgPlane.BackgroundOffset = mLeftCamera.transform.position - DigitalEyewearBehaviour.Instance.CentralAnchorPoint.position;

            mLeftExcessAreaBehaviour.PlaneOffset = mLeftCamera.transform.position - DigitalEyewearBehaviour.Instance.CentralAnchorPoint.position;
            mRightExcessAreaBehaviour.PlaneOffset = mRightCamera.transform.position - DigitalEyewearBehaviour.Instance.CentralAnchorPoint.position;

            if (TrackableParent != null)
                TrackableParent.localPosition = Vector3.zero;

            // update Vuforia explicitly
            VuforiaBehaviour.Instance.UpdateState(false, true);//报错

            if (TrackableParent != null)
                TrackableParent.position += bgPlane.BackgroundOffset;

            // set the projection matrices for skewing
            VuforiaBehaviour.Instance.ApplyCorrectedProjectionMatrix(mLeftCameraMatrixOriginal, true);//报错
            VuforiaBehaviour.Instance.ApplyCorrectedProjectionMatrix(mRightCameraMatrixOriginal, false);//报错

#if !(UNITY_5_2 || UNITY_5_1 || UNITY_5_0) // UNITY_5_3 and above

            // read back the projection matrices set by Vuforia and set them to the stereo cameras
            // not sure if the matrices would automatically propagate between the left and right, so setting it explicitly twice
            mLeftCamera.SetStereoProjectionMatrices(mLeftCamera.projectionMatrix, mRightCamera.projectionMatrix);
            mRightCamera.SetStereoProjectionMatrices(mLeftCamera.projectionMatrix, mRightCamera.projectionMatrix);

#endif
// reset the left camera
mLeftCamera.transform.localPosition = localPosLeftCam;
mLeftCamera.pixelRect = leftCamPixelRect;

            // reset the position of the right camera
            mRightCamera.transform.localPosition = localPosRightCam;
            mRightCamera.pixelRect = rightCamPixelRect;
        }
    }
}

// OnPreRender is called once per camera each frame
void OnPreRender()
{
    // on pre render is where projection matrix and pixel rect are set up correctly (for each camera individually)
    // so we use this to acquire this data.
    if (IsLeft && !mLeftCameraDataAcquired)
    {
        mLeftCameraMatrixOriginal = mLeftCamera.projectionMatrix;
        mLeftCameraPixelRect = mLeftCamera.pixelRect;
        mLeftCameraDataAcquired = true;
    }
    else if (!mRightCameraDataAcquired)
    {
        mRightCameraMatrixOriginal = mRightCamera.projectionMatrix;
        mRightCameraPixelRect = mRightCamera.pixelRect;
        mRightCameraDataAcquired = true;

    }
}

}
//inatance后面老报错,我没有添加实例么??还是没有传递什么参数??报CS1061的错误。。。。。

hyp_no_sis
hyp_no_sis   2016.04.03 15:20

是你的插件包所需的unity版本,跟你现有的导入插件的unity版本不匹配吧。

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!