Last active
January 8, 2020 21:25
-
-
Save julenka/c035834dec0dc66d80087ab6d07e1597 to your computer and use it in GitHub Desktop.
Check if any hand is pinching or pressed in MRTK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Approach using LINQ | |
| private bool IsAnyHandPressed() | |
| { | |
| return CoreServices.InputSystem.DetectedControllers | |
| .OfType<IMixedRealityHand>() | |
| .Any(h => h.Interactions.Any(i => i.InputType == DeviceInputType.Select && i.BoolData)); | |
| } | |
| // Approach using for loops | |
| private bool IsAnyHandPressed() | |
| { | |
| foreach (var controller in CoreServices.InputSystem.DetectedControllers) | |
| { | |
| if (controller is IMixedRealityHand) | |
| { | |
| for (int i = 0; i < controller.Interactions.Length; i++) | |
| { | |
| if(controller.Interactions[i].InputType == DeviceInputType.Select && controller.Interactions[i].BoolData) | |
| { | |
| return true; | |
| } | |
| } | |
| } | |
| } | |
| return false; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment