Log in or register to post comments

Getting click input from Hololens within Unity

July 25, 2017 - 3:04am #1

Hello all,

I am trying to work out how to get click input with the Hololens and having that to work with Vuforia. I've gone through Microsoft's Academy pages, one of the samples they provided had 4 Cubes, each doing something different when you click on them. I figured I could do that same thing so I transferred the InputManager and InteractiveMeshCursor prefabs into my project (including all the scripts required). I then had Cube object as a child of the ImageTarget.

I have a script attached to the Cube

public class ChangeColor : MonoBehaviour, IInputClickHandler  {

	public void OnInputClicked(InputClickedEventData e){

        Color random = new Color(Random.Range(0, 255), Random.Range(0, 255), Random.Range(0, 255));
        gameObject.GetComponent<MeshRenderer>().material.color = random;
    }

}

So what should happen is after I look at an ImageTarget, the cube should spawn and if I click on the cube, it should change to a random colour. However, when I deploy to device, it loads the application and spawn the objects, but when I click on the cube it does not change the colour. I can see the cursor changing when I do the click gesture.

Would like to know whether I am approaching this problem the right way.

Thanks

Getting click input from Hololens within Unity

August 4, 2017 - 1:44am #3

Google HoloToolkit. It is a package you can download and import into Unity. It contains loads of prefabs and scripts to get you started and building a hololens application very quickly. You can literally drop scripts onto objects and perform all the manipulations tasks etc.

Getting click input from Hololens within Unity

July 26, 2017 - 1:52am #2

I figured I would do an update. I managed to get it to work although I am not quite sure why it was not working when I tried to recreate the functionality from a new project . What I did in the end was that I took a copy of the Hololens Academy that had the touch interaction and then imported the Vuforia packages. I used one of the cubes from the Hololens sample project as a button and was able to use the OnInputClicked function.

Really confused right now, I literally copied all the scripts and prefabs from the Hololens project over and it did't work, so there must be something in the Hololens samples that I must've missed.

Oh and despite getting the button click to work, I've noticed a considerable amount of frames being dropped when I look at my image target, which appears to have an effect on the consistency of button clicking; sometimes I am able to do the click gesture and have it registered as an input, but other times it does not recognise the gesture (the cursor prefab does not change). I also think that the problem worsens when I look away from the image target and then look at it again.

Just a quick question; when uploading an image target via the website, does the width have an impact on performance?

Edit: Scratch that, turns out that the the graphics quality was set to fantastic rather than fastet, bit odd that the project was set to that by default when it was uploaded. I'd also disable anti-aliasing in the graphics quality settings

Thanks

Log in or register to post comments