void Start() { HandController[] allControllers = FindObjectsOfType<HandController> (); foreach (HandController controller in allControllers) { if (controller.isActiveAndEnabled) { handController = controller; } } if (handController == null) { Debug.LogWarning ("Camera alignment requires an active HandController in the scene -> enabled = false"); enabled = false; return; } LeapImageRetriever[] allRetrievers = FindObjectsOfType<LeapImageRetriever> (); foreach (LeapImageRetriever retriever in allRetrievers) { if (retriever.isActiveAndEnabled) { imageRetriever = retriever; } } /*if (imageRetriever == null) { Debug.LogWarning ("Camera alignment requires an active LeapImageRetriever in the scene -> enabled = false"); enabled = false; return; }*/ hasCameras = VRCameras.NONE; if (centerCamera != null) { Camera center = centerCamera.GetComponent<Camera>(); if (center != null && center.isActiveAndEnabled) { hasCameras = VRCameras.CENTER; } } if (hasCameras == VRCameras.NONE) { Camera left = leftCamera.GetComponent<Camera>(); Camera right = rightCamera.GetComponent<Camera>(); if (left != null && left.isActiveAndEnabled && right != null && right.isActiveAndEnabled) { hasCameras = VRCameras.LEFT_RIGHT; } } if (hasCameras == VRCameras.NONE) { Debug.LogWarning ("Either a central Camera for both eyes, or a Left and Right cameras must be referenced -> enabled = false"); enabled = false; return; } if (transform.parent == null) { Debug.LogWarning ("Alignment requires a parent object to define the location of the player in the world. enabled -> false"); enabled = false; return; } if (transform != leftCamera.parent || transform != centerCamera.parent || transform != rightCamera.parent) { Debug.LogWarning ("LeapCameraAlignment must be a component of the parent of the camera tranasforms -> enabled = false"); enabled = false; return; } deviceInfo = (overrideDeviceType) ? new LeapDeviceInfo(overrideDeviceTypeWith) : handController.GetDeviceInfo (); if (deviceInfo.type == LeapDeviceType.Invalid) { Debug.LogWarning ("Invalid Leap Device -> enabled = false"); enabled = false; return; } if (VRDevice.isPresent && VRSettings.loadedDevice == VRDeviceType.Oculus) { eyeAlignment = new UserEyeAlignment() { use = true, ipd = OVRPlugin.ipd, eyeDepth = OVRPlugin.eyeDepth, eyeHeight = OVRPlugin.eyeHeight }; Debug.Log ("Unity VR Support with Oculus"); } else { eyeAlignment = new UserEyeAlignment() { use = false, ipd = 0f, eyeDepth = 0f, eyeHeight = 0f }; Debug.Log ("Two-camera stereoscopic alignment"); } }
void Start() { HandController[] allControllers = FindObjectsOfType <HandController> (); foreach (HandController controller in allControllers) { if (controller.isActiveAndEnabled) { handController = controller; } } if (handController == null) { //Debug.LogWarning ("Camera alignment requires an active HandController in the scene -> enabled = false"); enabled = false; return; } LeapImageRetriever[] allRetrievers = FindObjectsOfType <LeapImageRetriever> (); foreach (LeapImageRetriever retriever in allRetrievers) { if (retriever.isActiveAndEnabled) { imageRetriever = retriever; } } /*if (imageRetriever == null) { * //Debug.LogWarning ("Camera alignment requires an active LeapImageRetriever in the scene -> enabled = false"); * enabled = false; * return; * }*/ hasCameras = VRCameras.NONE; if (centerCamera != null) { Camera center = centerCamera.GetComponent <Camera>(); if (center != null && center.isActiveAndEnabled) { hasCameras = VRCameras.CENTER; } } if (hasCameras == VRCameras.NONE) { Camera left = leftCamera.GetComponent <Camera>(); Camera right = rightCamera.GetComponent <Camera>(); if (left != null && left.isActiveAndEnabled && right != null && right.isActiveAndEnabled) { hasCameras = VRCameras.LEFT_RIGHT; } } if (hasCameras == VRCameras.NONE) { //Debug.LogWarning ("Either a central Camera for both eyes, or a Left and Right cameras must be referenced -> enabled = false"); enabled = false; return; } if (transform.parent == null) { //Debug.LogWarning ("Alignment requires a parent object to define the location of the player in the world. enabled -> false"); enabled = false; return; } if (transform != leftCamera.parent || transform != centerCamera.parent || transform != rightCamera.parent) { //Debug.LogWarning ("LeapCameraAlignment must be a component of the parent of the camera tranasforms -> enabled = false"); enabled = false; return; } deviceInfo = (overrideDeviceType) ? new LeapDeviceInfo(overrideDeviceTypeWith) : handController.GetDeviceInfo(); if (deviceInfo.type == LeapDeviceType.Invalid) { //Debug.LogWarning ("Invalid Leap Device -> enabled = false"); enabled = false; return; } if (VRDevice.isPresent && VRSettings.loadedDevice == VRDeviceType.Oculus) { eyeAlignment = new UserEyeAlignment() { use = true, ipd = OVRPlugin.ipd, eyeDepth = OVRPlugin.eyeDepth, eyeHeight = OVRPlugin.eyeHeight }; //Debug.Log ("Unity VR Support with Oculus"); } else { eyeAlignment = new UserEyeAlignment() { use = false, ipd = 0f, eyeDepth = 0f, eyeHeight = 0f }; //Debug.Log ("Two-camera stereoscopic alignment"); } }