private void Update_SteamVR()
 {
     for (int i = 0; i < trackedObjects.Length; i++)
     {
         TrackedDevicePose_t pose = trackedObjects[i];
         if (pose.bDeviceIsConnected)
         {
             if (string.IsNullOrEmpty(trackedObjectGuids[i]))
             {
                 string checkGuid = VRInfo.GetDeviceSerial((uint)i);
                 if (!string.IsNullOrEmpty(checkGuid))
                 {
                     trackedObjectGuids[i] = checkGuid;
                 }
             }
         }
         else
         {
             trackedObjectGuids[i] = null;
         }
     }
 }
        bool GetTrackedTransform_Steam(out Vector3 pos, out Quaternion rot)
        {
            pos = Vector3.zero;
            rot = Quaternion.identity;

            if (string.IsNullOrEmpty(context.Data.trackedByDeviceId))
            {
                lastTrackingDeviceId = null;
                if (!string.IsNullOrEmpty(context.Data.trackedByDevice))
                {
                    SteamVR_TrackedObject.EIndex deviceIndex = (SteamVR_TrackedObject.EIndex)System.Enum.Parse(typeof(SteamVR_TrackedObject.EIndex), context.Data.trackedByDevice);
                    context.Data.trackedByDeviceId = VRInfo.GetDeviceSerial((uint)deviceIndex);
                }
                else
                {
                    return(false);
                }
            }

            try
            {
                if (lastTrackingDeviceId != context.Data.trackedByDeviceId)
                {
                    if (trackedObject == null)
                    {
                        var proxy = new GameObject("Tracking Proxy");
                        proxy.transform.parent = transform;
                        trackedObject          = proxy.AddComponent <SteamVR_TrackedObject>();
                    }

                    lastTrackingDeviceId = null;

                    for (int i = 0; i < Valve.VR.OpenVR.k_unMaxTrackedDeviceCount; i++)
                    {
                        string deviceId = VRInfo.GetDeviceSerial((uint)i);
                        if (deviceId == context.Data.trackedByDeviceId)
                        {
                            trackedObject.SetDeviceIndex(i);
                            trackedObject.enabled = false;  //Reset component so trackedObject.isValid will be helpful again
                            trackedObject.enabled = true;
                            lastTrackingDeviceId  = context.Data.trackedByDeviceId;
                            break;
                        }
                    }
                    newPosesAppliedAction.enabled = true;
                    isTrackedDeviceReady          = false;

                    return(false);
                }

                if (!isTrackedDeviceReady ||
                    string.IsNullOrEmpty(lastTrackingDeviceId) ||
                    trackedObject == null ||
                    !trackedObject.isValid)
                {
                    return(false);
                }

                pos = trackedObject.transform.localPosition;
                rot = trackedObject.transform.localRotation;

                return(true);
            }
            catch (System.Exception)
            {
                return(false);
            }
        }