Scale tool with Gesture Recognizer

The next tool we'll implement is the Scale tool that lets you resize the picture. Like the Move tool, it uses an update sequencing design pattern to implement a modal manipulation tool. However, we'll use a different user scenario, and a different underlying implementation.

The Scale tool will work like this:

  • Pressing and holding the button using the finger-thumb pinch gesture will activate the scale manipulation mode. The button will grow enlarged to show it is activated.
  • As you continue to hold the pinch gesture and move your gaze to the right, the picture object gets bigger. Move your gaze to the left and the picture shrinks.
  • Releasing the pinch gesture (unclicking the button) deactivates Move mode, restores the button icon to its normal size, and leaves the picture in its new position.

So, this tool provides an example that operates differently than the Move tool. With the Move tool, you click once (and release) to begin moving, and then click again to stop. This tool will be a click-and-hold operation instead.

Also, we use this example to show a different way of accessing HoloLens input events. In our other UI elements, we use the InputManager and, specifically, the IInputClickHandler interface to respond to OnInputClicked events. For the Scale tool, we use the lower level, Unity built-in GestureRecognizer class. (See the Unity API manual https://docs.unity3d.com/ScriptReference/VR.WSA.Input.GestureRecognizer.html). To use GestureRecognizer, you specify which gesture types you want to capture, and then register callback functions to be called when one of those events occurs.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.128.190.102