public override void OnDeactivated() { SteamVR_Events.InputFocus.RemoveListener(OnInputFocus); SteamVR_Events.System(EVREventType.VREvent_TrackedDeviceRoleChanged).RemoveListener(OnTrackedDeviceRoleChanged); SteamVR_Input.OnNonVisualActionsUpdated -= UpdateDeviceInput; SteamVR_Input.OnPosesUpdated -= UpdateDevicePose; trackingSpace = m_prevTrackingSpace; s_moduleInstance = null; }
public override void OnActivated() { m_digitalDataSize = (uint)Marshal.SizeOf(new InputDigitalActionData_t()); m_analogDataSize = (uint)Marshal.SizeOf(new InputAnalogActionData_t()); m_originInfoSize = (uint)Marshal.SizeOf(new InputOriginInfo_t()); m_activeActionSetSize = (uint)Marshal.SizeOf(new VRActiveActionSet_t()); m_poses = new TrackedDevicePose_t[OpenVR.k_unMaxTrackedDeviceCount]; m_gamePoses = new TrackedDevicePose_t[0]; m_originDataCache = new Dictionary <ulong, OriginData>((int)OpenVR.k_unMaxActionOriginCount); InitializeHandles(); m_activeActionSets = new VRActiveActionSet_t[1] { new VRActiveActionSet_t() { ulActionSet = s_actionSetHandle, } }; SteamVR_Input.OnNonVisualActionsUpdated += UpdateDeviceInput; SteamVR_Input.OnPosesUpdated += UpdateDevicePose; s_devicePathHandles = new ulong[OpenVR.k_unMaxTrackedDeviceCount]; EnsureDeviceStateLength(OpenVR.k_unMaxTrackedDeviceCount); // preserve previous tracking space m_prevTrackingSpace = trackingSpace; m_hasInputFocus = inputFocus; SteamVR_Events.InputFocus.AddListener(OnInputFocus); SteamVR_Events.System(EVREventType.VREvent_TrackedDeviceRoleChanged).AddListener(OnTrackedDeviceRoleChanged); s_moduleInstance = this; }