Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions org.mixedrealitytoolkit.core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## Unreleased

### Added

* Added input action focus handling to disable controller/hand tracked state when the application goes out of focus. [PR #1039](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/1039)

### Changed

* Updated the MRTK Default Profile to use the Unity XR Hands subsystem by default instead of the Microsoft OpenXR Plugin subsystem. [PR #973](https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity/pull/973)
Expand Down
31 changes: 31 additions & 0 deletions org.mixedrealitytoolkit.core/Subsystems/MRTKLifecycleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using Unity.Profiling;
using UnityEngine;
using UnityEngine.InputSystem;

namespace MixedReality.Toolkit.Subsystems
{
Expand All @@ -18,6 +19,9 @@ public class MRTKLifecycleManager :
MonoBehaviour,
IDisposable
{
[SerializeField, Tooltip("A set of input actions to enable/disable according to the app's focus state.")]
private InputActionReference[] inputActionReferences;

private List<IMRTKManagedSubsystem> managedSubsystems = new List<IMRTKManagedSubsystem>();

/// <summary>
Expand Down Expand Up @@ -176,6 +180,33 @@ private void LateUpdate()
}
}

/// <summary>
/// Sent to all GameObjects when the player gets or loses focus.
/// </summary>
/// <param name="focus"><see langword="true"/> if the GameObjects have focus, else <see langword="false"/>.</param>
protected void OnApplicationFocus(bool focus)
{
// We want to ensure we're focused for input, as some runtimes continue reporting "tracked" while pose updates are paused.
// This is allowed, per-spec, as a "should": "Runtimes should make input actions inactive while the application is unfocused,
// and applications should react to an inactive input action by skipping rendering of that action's input avatar
// (depictions of hands or other tracked objects controlled by the user)."

if (focus)
{
foreach (InputActionReference reference in inputActionReferences)
{
reference.action.Enable();
Comment thread
keveleigh marked this conversation as resolved.
}
}
else
{
foreach (InputActionReference reference in inputActionReferences)
{
reference.action.Disable();
}
}
}

#endregion MonoBehaviour

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion org.mixedrealitytoolkit.core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "org.mixedrealitytoolkit.core",
"version": "4.0.0-development.pre.1",
"version": "4.0.0-development.pre.2",
"description": "A limited collection of common interfaces and utilities that most MRTK packages share. Most implementations of these interfaces are contained in other packages in the MRTK ecosystem.",
"displayName": "MRTK Core Definitions",
"msftFeatureCategory": "MRTK3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 1a107350295baaf4489642caa92f05de, type: 3}
m_Name:
m_EditorClassIdentifier:
inputActionReferences:
- {fileID: -7613329581162844239, guid: 18c412191cdc9274897f101c7fd5316f, type: 3}
- {fileID: 3239510804178183174, guid: 18c412191cdc9274897f101c7fd5316f, type: 3}
--- !u!1 &7735890427496681069
GameObject:
m_ObjectHideFlags: 0
Expand Down