コード例 #1
0
        public SteamVR_ControllerManager()
        {
            // Add left and right entries to the head of the list so we only have to operate on the list itself.
            var additional = (this.objects != null) ? this.objects.Length : 0;
            var objects    = new SteamVR_Controller[2 + additional];

            indices    = new uint[2 + additional];
            objects[0] = right;
            indices[0] = OpenVR.k_unTrackedDeviceIndexInvalid;
            objects[1] = left;
            indices[1] = OpenVR.k_unTrackedDeviceIndexInvalid;
            for (int i = 0; i < additional; i++)
            {
                objects[2 + i] = this.objects[i];
                indices[2 + i] = OpenVR.k_unTrackedDeviceIndexInvalid;
            }
            this.objects = objects;

            for (int i = 0; i < objects.Length; i++)
            {
                var obj = objects[i];
                if (obj != null)
                {
                    obj.SetActive(false);
                }
            }

            OnTrackedDeviceRoleChanged();

            for (int i = 0; i < SteamVR.connected.Length; i++)
            {
                if (SteamVR.connected[i])
                {
                    OnDeviceConnected(i, true);
                }
            }

            SteamVR_Event.Listen("input_focus", OnInputFocus);
            SteamVR_Event.Listen("device_connected", OnDeviceConnected);
            SteamVR_Event.Listen("TrackedDeviceRoleChanged", OnTrackedDeviceRoleChanged);
        }
コード例 #2
0
 private void Dispose(bool disposing)
 {
     SteamVR_Event.Remove("input_focus", OnInputFocus);
     SteamVR_Event.Remove("device_connected", OnDeviceConnected);
     SteamVR_Event.Remove("TrackedDeviceRoleChanged", OnTrackedDeviceRoleChanged);
 }