VR Selection of buttons only works once unless scene refreshed.
This is my first question on this forum, so apologies if I haven't got the etiquette right.
Unity Version: 2019.4.21f1
Using Unity, I'm working on a very basic VR project (for Android devices) and on the UI there are a number of buttons that when selected open up dialogue boxes with additional information (instructions etc). These buttons are selected using a ray interactor. I have scripts to open and close the dialogue which all work the first time.
The ray interactor has a red dot that gives the user a reference point and when selecting the buttons there is a gazecircle for 2 seconds before the dialogue box appears/ disappears.
The issue is that I can open and close a dialogue boxes the first time in the scene but they will not open a second time unless I exit and reenter the scene. However the gaze circle still works
Any help would be gratefully received.
The code is as below (which has been adapted from code on a Youtube tutorial):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class popUpHealthOpen : MonoBehaviour
{
public GameObject healthWarnPanel;
public Image gazeCircle;
public float totalTime = 2;
bool gvrStatus = false;
public float gvrTimer = 0;
void Start()
{
gazeCircle.fillAmount = 0;
}
void Update()
{
if (gvrStatus)
{
gvrTimer += Time.deltaTime;
gazeCircle.fillAmount = gvrTimer / totalTime;
}
if (gvrTimer > totalTime)
{
gazeCircle.fillAmount = 0;
healthWarnPanel.SetActive(true);
}
}
public void OnPointerEnter()
{
gvrStatus = true;
}
public void OnPointerExit()
{
gvrStatus = false;
gvrTimer = 0;
gazeCircle.fillAmount = 0;
}
}
Your answer
Follow this Question
Related Questions
Get Direction From Raycast 0 Answers
raycast activation by trigger 0 Answers