Implementation of Closing Panel would be a small exercise for you to consider using Gaze and Gesture; we will try to keep this short and simple here:
- Add a box collider with the cross images inside the panel.
- Add a new script called DialogCloseHandler.cs inside the Script folder.
- Open the class in Visual Studio and implement the InputClickHandler interface.
Add the following line of code inside the OnInputClicked() method that just takes reference of the DetailsPanel Game Object and sets the alpha to its CanvasGroup's renderer components to 0:
public void OnInputClicked(InputEventData eventData)
{
GameObject detailsPanel =
GameObject.FindWithTag("DetailsPanel");
if (detailsPanel != null)
{
CanvasGroup detailsPanelRenderer =
detailsPanel.GetComponentInChildren<CanvasGroup>();
detailsPanelRenderer.alpha = 0;
}
}
Finally, attach the script with Close image control from the Inspector windows. That's it.