Esempio n. 1
0
    private Transform ConfigureEyeAnchor(Transform root, UnityEngine.VR.VRNode eye)
#endif
    {
#if UNITY_2017_2_OR_NEWER
        string eyeName = (eye == UnityEngine.XR.XRNode.CenterEye) ? "Center" : (eye == UnityEngine.XR.XRNode.LeftEye) ? "Left" : "Right";
#else
        string eyeName = (eye == UnityEngine.VR.VRNode.CenterEye) ? "Center" : (eye == UnityEngine.VR.VRNode.LeftEye) ? "Left" : "Right";
#endif
        string    name   = eyeName + eyeAnchorName;
        Transform anchor = transform.Find(root.name + "/" + name);

        if (anchor == null)
        {
            anchor = transform.Find(name);
        }

        if (anchor == null)
        {
            string legacyName = legacyEyeAnchorName + eye.ToString();
            anchor = transform.Find(legacyName);
        }

        if (anchor == null)
        {
            anchor = new GameObject(name).transform;
        }

        anchor.name          = name;
        anchor.parent        = root;
        anchor.localScale    = Vector3.one;
        anchor.localPosition = Vector3.zero;
        anchor.localRotation = Quaternion.identity;

        return(anchor);
    }
    private LeapImageRetriever getImageRetreiverForEye(UnityEngine.VR.VRNode eyeNode)
    {
        Camera             cameraForEye         = getCameraObjectForEye(eyeNode);
        LeapImageRetriever imageRetrieverForEye = cameraForEye.gameObject.GetComponent <LeapImageRetriever>();

        if (cameraForEye == null)
        {
            throw new System.NullReferenceException("Could not resolve the camera for the given eye: " + eyeNode.ToString());
        }

        if (imageRetrieverForEye == null)
        {
            throw new UnityEngine.MissingComponentException("Could not find LeapImageRetriever component adjacent to camera on " + cameraForEye.gameObject.name + " for the given eye: " + eyeNode.ToString());
        }

        return(imageRetrieverForEye);
    }
    private Camera getCameraObjectForEye(UnityEngine.VR.VRNode cameraNode)
    {
        Camera camera;

        switch (cameraNode)
        {
        case UnityEngine.VR.VRNode.CenterEye:
        case UnityEngine.VR.VRNode.Head:
            camera = ((HMRConfigurationManager)target)._centerCamera;
            break;

        case UnityEngine.VR.VRNode.LeftEye:
            camera = ((HMRConfigurationManager)target)._leftCamera;
            break;

        case UnityEngine.VR.VRNode.RightEye:
            camera = ((HMRConfigurationManager)target)._rightCamera;
            break;

        default:
            throw new System.ArgumentOutOfRangeException("No understoof VRNode provided.");
        }

        if (camera == null)
        {
            throw new System.NullReferenceException("The camera reference for the " + cameraNode.ToString() + "is missing on " + ((HMRConfigurationManager)target).gameObject.name);
        }

        return(camera);
    }