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

How do I activate a popup menu on focus?

Hello.

I am working on an application for Hololens in which I wish to enable a child of a game object through focusing my gaze on it, and then keep it active by gazing either on the parent, or on the child itself. It should disable itself once the parent or the child are no longer in focus. Like a pop up menu.

Currently, I am using a boolean in a script attached to the parent, and two functions which can enable/disable the boolean. I call these functions in a script attached to the child. The boolean tells the parent if the child is in focus. If the parent and the child are not in focus, the child gets disabled.

Here is an example of how it works:

Parent class:
public class Parent : MonoBehaviour, IFocusable
{
private bool childFocused = false;
public void OnFocusEnter()
{
ActivateChild();
}
public void OnFocusExit()
{
if (childFocused == false)
{
DeactivateChild();
}
public void TurnOnFocus()
{
childFocused = true;
}
public void TurnOffFocus()
{
childFocused = false;
}
}

Child class:
public class Child : MonoBehaviour, IFocusable
{
public void OnFocusEnter()
{
ActivateChild();
gameObject.GetComponent().TurnOnFocus();
}
public void OnFocusExit()
{
gameObject.GetComponent().TurnOffFocus();
}
}

It is not working properly though. Sometimes the child stays active indefinitely, other times it closes immediately.
Any ideas or suggestions to what might be wrong would be greatly appreciated. Thank you in advance.

Tagged:
Sign In or Register to comment.