The Mixed Reality Forums here are no longer being used or maintained.
There are a few other places we would like to direct you to for support, both from Microsoft and from the community.
The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.
For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.
If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.
And always feel free to hit us up on Twitter @MxdRealityDev.
Add navigation gesture
Hi everyone, I read this pull request https://github.com/Microsoft/HoloToolkit-Unity/pull/196 and I'm using the new script GestureManager of HoloToolkit for manipulation. It works very well but now I want to add navigation like in Holograms 211. How can I do? Are there some examples I can follow?
Best Answer
-
Optionsjames_ashley ✭✭✭✭
I can try to get you started. The holotoolkit uses a GestureManager and GestureManipulator. To get navigation working, then, you'll want to modify the GestureManager in the toolkit and also add a RotationManipulator to handle the navigation events. Here's what that would look like:
public class RotationManipulator : MonoBehaviour
{[Tooltip("Rotation max speed controls amount of rotation.")] public float RotationSensitivity = 5.0f; private Vector3 manipulationPreviousPosition; private float rotationFactor; private bool hasFocus = false; void Update() { if (hasFocus) PerformRotation(); } private void PerformRotation() { if (GestureManager.Instance.IsNavigating) { // Calculate rotationFactor based on GestureManager's NavigationPosition.X and multiply by RotationSensitivity. // This will help control the amount of rotation. rotationFactor = GestureManager.Instance.NavigationPosition.x * RotationSensitivity; // transform.Rotate along the Y axis using rotationFactor. transform.Rotate(new Vector3(0, -1 * rotationFactor, 0)); } }
}
Then pull in some of the code from the 211 GestureManager into your HoloToolkit GestureManager class. Especially setting up Navigation events in your Start or Awake method:
gestureRecognizer = new GestureRecognizer(); gestureRecognizer.SetRecognizableGestures(GestureSettings.NavigationX | GestureSettings.Tap); gestureRecognizer.TappedEvent += GestureRecognizer_TappedEvent; gestureRecognizer.NavigationStartedEvent += NavigationRecognizer_NavigationStartedEvent; gestureRecognizer.NavigationUpdatedEvent += NavigationRecognizer_NavigationUpdatedEvent; gestureRecognizer.NavigationCompletedEvent += NavigationRecognizer_NavigationCompletedEvent; gestureRecognizer.NavigationCanceledEvent += NavigationRecognizer_NavigationCanceledEvent;
If you keep following the tutorial, you'll want to implement the void Transition(GestureRecognizer newRecognizer) method, also, so you can switch between navigating to rotate the astronaut and manipulating to move him.
James Ashley
VS 2017 v5.3.3, Unity 2017.3.0f3, MRTK 2017.1.2, W10 17063
Microsoft MVP, Freelance HoloLens/MR Developer
www.imaginativeuniversal.com5
Answers
I can try to get you started. The holotoolkit uses a GestureManager and GestureManipulator. To get navigation working, then, you'll want to modify the GestureManager in the toolkit and also add a RotationManipulator to handle the navigation events. Here's what that would look like:
public class RotationManipulator : MonoBehaviour
{
}
Then pull in some of the code from the 211 GestureManager into your HoloToolkit GestureManager class. Especially setting up Navigation events in your Start or Awake method:
If you keep following the tutorial, you'll want to implement the void Transition(GestureRecognizer newRecognizer) method, also, so you can switch between navigating to rotate the astronaut and manipulating to move him.
James Ashley
VS 2017 v5.3.3, Unity 2017.3.0f3, MRTK 2017.1.2, W10 17063
Microsoft MVP, Freelance HoloLens/MR Developer
www.imaginativeuniversal.com