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.
Canvas to appear on Airtap Gesture using IInputClickHandler
Hi,
For some reason I am not able to locate a script that can help me activate and destroy a menu using Airtap. I have already built the menu using a canvas and I have positioned it appropriately. Can anyone point me in the direction of the appropriate c# script?
Thanks
Tagged:
0
Best Answer
-
Reeley ✭✭✭
Oh okey so basically you want a menu which will open when clicking your gameobject (Monkey1).
If so then we dont need the globalListener since you have the script attached to a gameobject which you click.Also we dont want to destroy the canvas, if its destroyed we cant re-activate it, because its gone. So lets set it active and inactive. I guess thats the behaviour you want.
public class InteractibleManager: MonoBehaviour, IInputClickHandler { public GameObject Canvas1; bool active = false; public void OnInputClicked(InputClickedEventData eventData) { if (!active) { Canvas1.SetActive(true); destroy = true; } else { Canvas1.SetActive(false); active = false; } } }
5
Answers
This will activate your Canvas on the first airtap and destroy it on the second airtap:
Just attach this script to an empty gameobject and assign your canvas
Thanks for getting back to me! You are a Ninja!
Maybe I am doing something wrong but I implemented your script and the only thing that is happening is my canvas (Canvas1) is closing "if" I have it active within the Hierarchy.
If I click on my gameObject (Monkey1), that your script is assigned to after that, nothing happens.
The way my hierarchy is set up is that my canvas (Canvas1) is a child of the gameObject (Monkey1). Here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HoloToolkit.Unity.InputModule;
I was hoping to have the canvas non active until the gameObject is clicked on and then destroyed once it is clicked on again. This could happen over and over sort of like a menu.
I really appreciate your help in this!!!
Oh okey so basically you want a menu which will open when clicking your gameobject (Monkey1).
If so then we dont need the globalListener since you have the script attached to a gameobject which you click.
Also we dont want to destroy the canvas, if its destroyed we cant re-activate it, because its gone. So lets set it active and inactive. I guess thats the behaviour you want.
Works perfectly! Thank you very much for your help! I am in your dept.