private void OnEnable()
        {
            if (_newPosesAction != null)
            {
                _newPosesAction.enabled = true;
            }

            _instance = SteamVR.instance;
            if (_instance == null)
            {
                return;
            }

            _deviceIndex        = (int)_steamVrTrackedObject.index;
            _deviceType         = GetDeviceType((uint)_deviceIndex);
            _deviceSerialNumber =
                _instance.GetStringProperty(ETrackedDeviceProperty.Prop_SerialNumber_String, (uint)_deviceIndex);
        }
コード例 #2
0
    private void OnNewPoses(TrackedDevicePose_t[] poses)
    {
        if (!m_SteamVR_TrackedObject.isValid)
        {
            return;
        }

        int index = (int)m_SteamVR_TrackedObject.index;

        if (index == -1)
        {
            return;
        }

        if (poses.Length <= index)
        {
            return;
        }

        if (!poses[index].bDeviceIsConnected)
        {
            return;
        }

        if (!poses[index].bPoseIsValid)
        {
            return;
        }

        if (poses[index].eTrackingResult != ETrackingResult.Running_OK)
        {
            return;
        }

        // set index on this device
        m_Index = index;

        // get and check device type
        OPTDeviceType type = GetDeviceClass(index);

        if (type == OPTDeviceType.Unknown)
        {
            return;
        }

        // get and check device serial number
        string deviceSN = GetStringProperty((uint)index, ETrackedDeviceProperty.Prop_SerialNumber_String);

        if (deviceSN == null)
        {
            return;
        }

        m_DeviceSerialNumber = deviceSN;

        // get device position and rotation
        var        pose = new SteamVR_Utils.RigidTransform(poses[index].mDeviceToAbsoluteTracking);
        Vector3    pos  = pose.pos;
        Quaternion rot  = pose.rot;

        HI5_DataTransform.PushOpticalData(deviceSN, type, pos, rot);

        if (HI5_BindInfoManager.IsGloveBinded(Hand.LEFT) && HI5_BindInfoManager.IsGloveBinded(Hand.RIGHT))
        {
            return;
        }

        CheckDeviceBinded(index);
    }