// Update is called once per frame
    void Update()
    {
        List <Device> vrpnDevices = (from device in InputManager.map.Devices
                                     where device is VRPN
                                     select device).ToList();

        if (VRPNTimeline == VRPNTimelineType.Off ||
            timelines.Count != vrpnDevices.Count())
        {
            foreach (TimeLine iv in timelines)
            {
                Destroy(iv.gameObject);
            }
            timelines.Clear();
        }

        if (VRPNTimeline != VRPNTimelineType.Off)
        {
            if (timelines.Count < vrpnDevices.Count)
            {
                for (int i = 0; i < vrpnDevices.Count; i++)
                {
                    GameObject plot = new GameObject();
                    plot.transform.parent = transform;
                    plot.name             = vrpnDevices[i].ToString();

                    TimeLine iv = plot.AddComponent <TimeLine>();
                    timelines.Add(iv);

                    plot.transform.localPosition =
                        new Vector3(0, -i * .3f);
                }
            }

            for (int i = 0; i < vrpnDevices.Count; i++)
            {
                // Only VRPN devices are shown.
                VRPN device = vrpnDevices[i] as VRPN;

                float value = 0f;

                if (VRPNTimeline == VRPNTimelineType.FromClusterInput)
                {
                    if (device.InputType == ClusterInputType.Axis)
                    {
                        value = ClusterInput.GetAxis(device.id);
                    }

                    if (device.InputType == ClusterInputType.Button)
                    {
                        value = ClusterInput.GetButton(device.id) ? 1f : 0f;
                    }
                }
                else
                {
                    object valueObject = null;

                    if (VRPNTimeline == VRPNTimelineType.FromDeviceClassRaw)
                    {
                        valueObject = device.GetRawValue();
                    }

                    if (VRPNTimeline == VRPNTimelineType.FromDeviceClassTransformed)
                    {
                        valueObject = device.GetValue();
                    }

                    value = (device.GetRawValue() as float?).GetValueOrDefault();

                    if (valueObject is bool)
                    {
                        value = (valueObject as bool?).GetValueOrDefault() ? 1.0f : 0f;
                    }
                }

                timelines[i].AddPt(value);
            }
        }
    }