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.

Focus gaze on a panel

Hello everyone. I have a simple question. I am activating a panel with a few buttons and I want it to stay active while your gaze is on it, and deactivate once your gaze leaves the panel, like a pop-up menu ( with OnFocusEnter() and OnFocusExit() ). How can I focus on the panel with my gaze?

  • I've tried attaching a script with IFocusable, but it jumps to OnFocusExit() once it enters the gaze, and deactivates it.
  • I've tried doing a Raycast and keeping the panel open if the Raycast hits it. (I added a collider to the panel)

If you have any ideas how to do it, please share. Thanks.

Tagged:

Answers

  • Does your panel have a collider on it that covers the entire panel? And is there anything in front of your panel?

    What are you doing OnFocusEnter? I am wondering if something is changing OnEnter that is blocking your gaze and thus triggers the exit.

    We have an interactible class specifically for Gaze here:

    `
    public class GazeInteractible : MonoBehaviour, IFocusable
    {
    public CustomEvent OnGazeEnterHandler;
    public CustomEvent OnGazeLeaveHandler;

    [Serializable]
    public class CustomEvent : UnityEvent { public int CustomId; }
    
    protected bool GazeOver = false;
    protected bool RealGazeOver = false;
    
    public float GazeDelayTime = 0f;
    private float gazeStartTime = 0f;
    private bool awaitingGazeTrigger = false;
    
    public virtual void OnFocusEnter()
    { 
        RegisterGaze();
        RealGazeOver = true;
    }
    
    public virtual void OnFocusExit()
    { 
        UnregisterGaze();
        RealGazeOver = false;
    }
    

    if !UNITY_EDITOR

    public virtual void OnMouseEnter()
    { 
        RegisterGaze();
    }
    
    public virtual void OnMouseExit()
    { 
        UnregisterGaze();
    }
    

    endif

    private void Update()
    {
        if (GazeOver && awaitingGazeTrigger)
        {
            float time = Time.time;
            if (gazeStartTime + GazeDelayTime < time)
            { 
                awaitingGazeTrigger = false;
    
                if (OnGazeEnterHandler != null) OnGazeEnterHandler.Invoke();
            }
        }
    }
    
    protected virtual void RegisterGaze()
    { 
        if (!GazeOver)
        {
            if (TQCursorManager.Instance != null) TQCursorManager.Instance.AddInteractible();
            GazeOver = true;
    
    
            if (OnGazeEnterHandler != null)
            {
                if (GazeDelayTime <= 0)
                {
                    OnGazeEnterHandler.Invoke();
                } else
                {
                    gazeStartTime = Time.time;
                    awaitingGazeTrigger = true; 
                }
            }
        }
    }
    
    protected virtual void UnregisterGaze(bool triggerOnLeaveHandler = true)
    {
        awaitingGazeTrigger = false;
        if (GazeOver)
        { 
            if (TQCursorManager.Instance != null) TQCursorManager.Instance.RemoveInteractible();
            GazeOver = false;
    
            if (triggerOnLeaveHandler && OnGazeLeaveHandler != null) OnGazeLeaveHandler.Invoke();
        }
    }
    
    protected virtual void OnDestroy()
    {
        UnregisterGaze(false);
    }
    
    protected virtual void OnDisable()
    {
        UnregisterGaze(false);
    }
    

    }
    `

    Taqtile

Sign In or Register to comment.