Hello everyone.

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.

Rotate slider similair to 3D viewer

c4ssh3rnc4ssh3rn
edited February 2017 in Questions And Answers

I want to create a rotate slider similar to the 3D viewer

Now I have this, but how do make the slider react to tap and drag. Now it only responds to tap gesture without being able to drag.

Anybody know how to do this?

Many thanks

Answers

  • Are you on the latest version of the toolkit? Have you included an InputManager prefab in your scene? I can't remember if InputManager superseded HoloLensInputModule or not but you might also want to check out these steps in this guide here. What you are attempting to do (drag a slider) should be supported.

    Now, having said all that, you might not want to use a slider at all. Instead, you might want to look at NavigationManipulation. This allows you to know how far the user has moved their hands from a "start point". Think of it almost like grabbing and dragging a joystick. Then you can optionally use a very simple UI element to show how far they have dragged from center. And you can use the distance from center to affect the rotation speed.

    This type of manipulation can be applied while the user is gazing directly at an object rather than forcing the user interact with a UI widget below the object. Direct manipulation is many times preferable over the indirect approach.

    Our Holographic world is here

    RoadToHolo.com      WikiHolo.net      @jbienz
    I work in Developer Experiences at Microsoft. My posts are based on my own experience and don't represent Microsoft or HoloLens.

  • Thanks for the suggestion, I now have something like this. Any tips on how to improve it?

    `
    using UnityEngine;
    using HoloToolkit.Unity.InputModule;

    public class HandRotate : MonoBehaviour, INavigationHandler
    {

    public float rotationSensitivity = 10.0f;
    
    private Vector3 manipulationPreviousPostion;
    private float rotationFactor;
    
    public void OnNavigationStarted(NavigationEventData eventData)
    {
    
    }
    
    public void OnNavigationUpdated(NavigationEventData eventData)
    {
    
        rotationFactor = eventData.CumulativeDelta.x * rotationSensitivity;
    
        transform.Rotate(new Vector3(0, -1 * rotationFactor, 0));
    }
    
    public void OnNavigationCompleted(NavigationEventData eventData)
    {
    
    }
    
    public void OnNavigationCanceled(NavigationEventData eventData)
    {
    
    }
    

    }
    `

  • I updated it again, any tips on improving or applying it to a UI element?

    using UnityEngine;
    using HoloToolkit.Unity.InputModule;

    public class HandRotate : MonoBehaviour, INavigationHandler
    {
    public float rotationSensitivity = 10.0f;
    private Vector3 manipulationPreviousRotation;
    private float rotationFactor;
    void Start() {}
    public void OnNavigationStarted(NavigationEventData eventData)
    {
    manipulationPreviousRotation = transform.localEulerAngles;
    }

    public void OnNavigationUpdated(NavigationEventData eventData)
    {
        rotationFactor = eventData.CumulativeDelta.x * rotationSensitivity;
        transform.localRotation = Quaternion.Euler(0, (-1 * rotationFactor) + manipulationPreviousRotation.y, 0);
    }
    
    public void OnNavigationCompleted(NavigationEventData eventData)
    {
    }
    
    public void OnNavigationCanceled(NavigationEventData eventData)
    {
    }
    

    }

  • @c4ssh3rn this is looking good! Maybe look into one of the cursor classes to see if you can emulate how rotation works in other apps. Maybe compare to the Holograms app. If I remember correctly there is a cursor that shows how far you've dragged away from center, which is a visual indicator of how fast the rotation speed is. Sorry I don't have any canned code for you on implementing something like this. But either way, your implementation looks great.

    Our Holographic world is here

    RoadToHolo.com      WikiHolo.net      @jbienz
    I work in Developer Experiences at Microsoft. My posts are based on my own experience and don't represent Microsoft or HoloLens.

Sign In or Register to comment.