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.
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.
tap gesture to SetActive gameobject
felsiska
✭
I have a script which SetActive canvas(with several buttons) when airtap anywhere. but canvas starts to flicker on and off after I airtap once and canvas unable to hide if airtap again. advice needed.
example code:
public GameObject canvas; void Start() { canvas.SetActive(false); } void Update() { if (GestureManager.instance.IsTapping) { canvas.SetActive(!canvas.ActiveSelf); } }
Tagged:
0
Answers
@felsiska is your script a component of the canvas or is it somewhere else in the hierarchy and if so where?
Have you tried moving this logic into a script that is not a component of the canvas.
The documentation for GameObject.SetActive mentions the following:
Windows Holographic User Group Redmond
WinHUGR.org - - - - - - - - - - - - - - - - - - @WinHUGR
WinHUGR YouTube Channel -- live streamed meetings
@HoloSheep
the script is a component of managers(another gameobject)
@felsiska how many times does the line:
if (GestureManager.instance.IsTapping)
evaluate to true when you air tap?
Perhaps that condition is firing multiple times each air tap which based on your ! logic would flip the value back and forth each tap.
You might want to stick a Debug.log statement in there to check if it fires multiple times.
Windows Holographic User Group Redmond
WinHUGR.org - - - - - - - - - - - - - - - - - - @WinHUGR
WinHUGR YouTube Channel -- live streamed meetings
@HoloSheep ,
thx for the advice. the ! logic in update does flip it back and forth does the flickering.
how do I implement OnSelect or OnTap when not gazing on any object? I'm trying to set the canvas active or inactive when tapping anywhere but not gameobject. tried
void OnTap()
andvoid OnSelect()
instead ofvoid Update()
but nothing happened.@felsiska
If you look at the GestrueRecognizer_TappedEvent you will see that it does a OnSelect sendMessage when the focusedObject != null.
You could mess with that and probably wire up a message to hand the focusedObject == null scenario... but I think that approach might take you down a rabbit hole that you might want to avoid.
One easy fix is to simply wire a voice command to hide and show the canvas.
Another approach would be to create some form of UI that is always visible that the use would gaze at to toggle the canvas on and off.
Another might be to have a menu that displays UI for turning on and off the canvas.
HTH
Windows Holographic User Group Redmond
WinHUGR.org - - - - - - - - - - - - - - - - - - @WinHUGR
WinHUGR YouTube Channel -- live streamed meetings
@HoloSheep
thx a lot for the advice. I am also currently using a simple menu that is always visible to toggle rest of ui on and off. seems like this will also be a safer and more friendly approach for users too.
thx for helping a lot!!! really appreciate it!