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.
Options

INavigationHandler events not firing

NickPNickP
edited February 2017 in Questions And Answers

I have a class that inherits from INavigationHandler that I attach to any object I want to rotate. I have put it on an object and tried to rotate it but even though the program goes into the Start() function of the script, the OnNavigationStarted() function never fires, and neither do any of the other Navigation functions.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HoloToolkit.Unity.InputModule;
using HoloToolkit.Unity;

public class TapAndHoldToRotate : MonoBehaviour, INavigationHandler
{
    public float RotationSensitivity = 10.0f;
    private Vector3 manipulationPreviousPosition;
    private float rotationFactor;
    // Use this for initialization
    void Start()
    {
        Debug.Log("Enter");
    }

    // Update is called once per frame
    void Update()
    {

    }

    public void OnNavigationUpdated(NavigationEventData eventData)
    {
        Debug.Log("Update");
        if (SceneManager.currentMode == 1)
        {
            rotationFactor = eventData.CumulativeDelta.x * RotationSensitivity;
            transform.Rotate(new Vector3(0, -1 * rotationFactor, 0));
        }
    }

    public void OnNavigationStarted(NavigationEventData eventData)
    {
        Debug.Log("Hi");
    }

    public void OnNavigationCompleted(NavigationEventData eventData)
    {
        Debug.Log("Complete");
    }

    public void OnNavigationCanceled(NavigationEventData eventData)
    {
        Debug.Log("Cancelled");
    }
}

Answers

  • Options

    Do you have an InputManager in your scene?

  • Options

    They won't fire in the editor, you need to deploy to the HoloLens emulator or the actual device to test

  • Options
    NickPNickP
    edited March 2017

    So what I have found out is that I cannot rotate the object anymore if I have the TapToRotate script on it as well as the TapToPlace script on it, even if TapToPlace is disabled.

    The code enters Update and the rotation is non-zero, according to my debug.logs but the model itself won't rotate.

    Why would that make a difference? If it's disabled it doesn't matter what's in the code, right?

    I am so close to this, please help

  • Options

    I am now calling Destroy() on TapToRotate and AddComponent to get a rotation script on the object when I switch modes from placement to rotation and it still doesn't work. It only seems to work if I have the rotation script on the object from the start and enabled, without the TapToPlace script on it too.

  • Options

    Don't know why this doesn't work, but have you tried to merge the two scripts into one?

  • Options

    If it helps, I have a simple drag/resize/rotate tutorial on my blog @ https://www.billmccrary.com/holotoolkit-simple-dragresizerotate/.

Sign In or Register to comment.