public void UpdateStatus() { if (!VivePose.IsConnected(m_deviceIndex)) { m_deviceIndex = ViveRole.INVALID_DEVICE_INDEX; textDeviceIndex.text = string.Empty; textDeviceClass.text = string.Empty; textSerialNum.text = string.Empty; textModelNum.text = string.Empty; } else { textDeviceIndex.text = m_deviceIndex.ToString(); textDeviceClass.text = ViveRole.GetDeviceClass(m_deviceIndex).ToString(); textSerialNum.text = ViveRole.GetSerialNumber(m_deviceIndex); textModelNum.text = ViveRole.GetModelNumber(m_deviceIndex); } }
public void UpdateStatus() { if (!VivePose.IsConnected(m_deviceIndex)) { m_deviceIndex = VRModule.INVALID_DEVICE_INDEX; textDeviceIndex.text = string.Empty; textDeviceClass.text = string.Empty; textSerialNum.text = string.Empty; textModelNum.text = string.Empty; } else { var deviceState = VRModule.GetCurrentDeviceState(m_deviceIndex); textDeviceIndex.text = m_deviceIndex.ToString(); textDeviceClass.text = deviceState.deviceClass.ToString();; textSerialNum.text = deviceState.serialNumber; textModelNum.text = deviceState.modelNumber; } }
public void UpdateState() { if (m_isUpdating) { return; } m_isUpdating = true; m_mappedDevice = m_map.GetMappedDeviceByRoleValue(m_roleValue); m_boundDeviceSN = m_map.GetBoundDeviceByRoleValue(m_roleValue); var mappedDeviceState = VRModule.GetCurrentDeviceState(m_mappedDevice); m_mappedDeviceSN = mappedDeviceState.serialNumber; var isMapped = VRModule.IsValidDeviceIndex(m_mappedDevice); var isBound = !string.IsNullOrEmpty(m_boundDeviceSN); var isSelectedValid = VivePose.IsConnected(m_selectedDevice); var isSelectingThisItem = isSelectedValid && (m_selectedDeviceSN == m_boundDeviceSN || m_selectedDevice == m_mappedDevice); // set background color imgBG.color = new Color(0f, 1f, 0f, isBound ? 1f : 0f); if (isMapped) { if (m_isPointed) { imgInnerBG.color = Color.yellow; } else { imgInnerBG.color = Color.white; } } else { imgInnerBG.color = Color.gray; } if (VRModule.IsValidDeviceIndex(m_selectedDevice)) { toggleBind.gameObject.SetActive(false); } else { toggleBind.gameObject.SetActive(isBound || isMapped); toggleBind.isOn = isBound; } buttonBind.SetActive(!isBound && isSelectedValid); textRoleName.text = m_map.RoleValueInfo.GetNameByRoleValue(m_roleValue); // update device icon if (mappedDeviceState.deviceClass == VRModuleDeviceClass.Invalid) { imgDeviceIcon.transform.parent.gameObject.SetActive(false); } else { imgDeviceIcon.transform.parent.gameObject.SetActive(true); imgDeviceIcon.sprite = deviceIconSprites[(int)mappedDeviceState.deviceClass - 1]; } if (isMapped) { textDeviceName.text = "[" + m_mappedDevice + "]" + " " + m_mappedDeviceSN; } else if (isBound) { textDeviceName.text = m_boundDeviceSN; } else { textDeviceName.text = string.Empty; } // heighLight selected item if (isSelectingThisItem) { textRoleName.color = Color.blue; textArrow.color = Color.blue; textDeviceName.color = Color.blue; } else { textRoleName.color = Color.black; textArrow.color = Color.black; textDeviceName.color = Color.black; } m_isUpdating = false; }
public virtual void OnNewPoses() { previousScannedDevice = currentScannedDevice; currentScannedDevice = ViveRole.INVALID_DEVICE_INDEX; for (uint i = 0; i < ViveRole.MAX_DEVICE_COUNT; ++i) { if (ChangeProp.Set(ref deviceConnected[i], VivePose.IsConnected(i))) { connectedDeviceChanged = true; if (!deviceConnected[i] && sentDevice == i) { if (sentDevice == i) { sentDevice = ViveRole.INVALID_DEVICE_INDEX; } if (scannedReticle != null) { scannedReticle.gameObject.SetActive(false); } } } if (!deviceConnected[i]) { continue; } var pose = VivePose.GetPose(i, VROrigin); if (sentDevice == i && scannedReticle != null) { scannedReticle.position = pose.pos; } hits[0] = null; var hitCount = Physics.OverlapSphereNonAlloc(pose.pos, radius, hits); if (hitCount > 0 && hits[0].transform.IsChildOf(transform)) { if (!ViveRole.IsValidIndex(currentScannedDevice)) { // not scanned any device yet this frame currentScannedDevice = i; } else { // multiple device scanned this frame currentScannedDevice = ViveRole.INVALID_DEVICE_INDEX; break; } hits[0] = null; } } if (previousScannedDevice != currentScannedDevice) { lastScannedChangedTime = Time.time; } }