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
Please Help! $$anonymous$$aybe I am doing something wrong but I've implemented this 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 ($$anonymous$$onkey1), that the below script is assigned to, nothing happens. The way my hierarchy is set up is that my canvas (Canvas1) is a child of the gameObject ($$anonymous$$onkey1). Here is my code.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HoloToolkit.Unity.Input$$anonymous$$odule;
public class Interactible$$anonymous$$anager: $$anonymous$$onoBehaviour, IInputClickHandler
{
public GameObject Canvas1;
bool destroy = false;
private void Start()
{
Input$$anonymous$$anager.Instance.AddGlobalListener(gameObject);
}
public void OnInputClicked(InputClickedEventData eventData)
{
if (!destroy)
{
Canvas1.SetActive(true);
destroy = true;
}
else
{
Destroy(Canvas1);
//Also destroy this script. We dont need it anymore since the canvas is destroyed!
Destroy(this);
}
}
}
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 anyones help in this!!!
Your answer
![](https://koobas.hobune.stream/wayback/20220612124550im_/https://answers.unity.com/themes/thub/images/avi.jpg)