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

Type `UnityEngine.VR.WSA.Input.GestureRecognizer' does not contain a definition for `HoldEvent'

abarsottiabarsotti
edited July 2016 in Questions And Answers

I'm trying to implement a hold gesture in my application according to this document https://developer.microsoft.com/en-us/windows/holographic/gestures_in_unity yet when I attempt to attach a listener via:
gestureRecognizer.HoldEvent += GestureRecognizer_HoldEvent;

I get the error:
Type 'UnityEngine.VR.WSA.Input.GestureRecognizer' does not contain a definition for 'HoldEvent'

Intellisense isn't working in Visual Studio and there is no documentation for the GestureRecognizer class making this impossible to debug. Does anyone know if that property has been renamed?

Best Answer

Answers

  • Options
    abarsottiabarsotti
    edited July 2016

    After implementing these events I still can't get them to trigger. I have a simple script based off of the TapToPlaceParent script in the Hololens 101 tutorial:

    ` using UnityEngine;
    using System.Collections;

        namespace HoloToolkit.Unity
        {
        public class HoldToPlaceParent : MonoBehaviour
        {
    
        bool placing = false;
    
        void OnHoldStart ()
        {
            if (SpatialMappingManager.Instance != null)
            {
                placing = true;
                    SpatialMappingManager.Instance.DrawVisualMeshes = true;
            }
        }
    
        void OnHoldComplete ()
        {
            if (SpatialMappingManager.Instance != null)
            {
                placing = false;
                        SpatialMappingManager.Instance.DrawVisualMeshes = false;
            }
        }
    
        void Update ()
        {
            if (placing)
            {
                var headPosition = Camera.main.transform.position;
                var gazeDirection = Camera.main.transform.forward;
    
                RaycastHit hitInfo;
    
                if (Physics.Raycast(headPosition, gazeDirection, out hitInfo, 30.0f, SpatialMappingManager.Instance.LayerMask))
                {
                    this.transform.parent.position = hitInfo.point;
    
                    Quaternion toQuat = Camera.main.transform.localRotation;
                    toQuat.x = 0;
                    toQuat.z = 0;
                    this.transform.parent.rotation = toQuat;
                }
            }
        }
        }
        }`
    

    And I have that attached to a game object where a tap event is currently being used and triggering correctly. I've modified the HoloToolkit's GestureManager script to include the HoldStarted and HoldCompleted Events as follows:

    gestureRecognizer.HoldStartedEvent += GestureRecognizer_HoldStartedEvent; gestureRecognizer.HoldCompletedEvent += GestureRecognizer_HoldCompletedEvent;

    in the Start method,

    ` private void OnHoldStart()
    {
    if (focusedObject != null)
    {
    focusedObject.SendMessage("OnHoldStart");
    }
    }

        private void OnHoldComplete()
        {
            if (focusedObject != null)
            {
                focusedObject.SendMessage("OnHoldComplete");
            }
        }
        private void GestureRecognizer_HoldStartedEvent(InteractionSourceKind source, Ray headRay)
        {
            OnHoldStart();
        }
    
    private void GestureRecognizer_HoldCompletedEvent(InteractionSourceKind source, Ray headRay)
        {
            OnHoldComplete();
        }`
    

    implemented within the class, and then I'm deregistering the events in OnDestroy.

Sign In or Register to comment.