Search Unity

gaze and pick with a delay

Discussion in 'AR/VR (XR) Discussion' started by lz7cjc, Oct 20, 2019.

  1. lz7cjc

    lz7cjc

    Joined:
    Sep 10, 2019
    Posts:
    538
    Hi
    After watching a few tutorials, I have managed to implement gaze and pick and now i need to include a delay so the player doesn't mistakenly change scene when their gaze just passes over the button. I have tried following a few tutorials but I can't get the delay to be dependent on the focus remaining on the button. This is what I have in my script:

    using UnityEngine;
    using UnityEngine.SceneManagement;

    public class LoadLevelAfterTime : MonoBehaviour
    {
    [SerializeField]
    private float DelayBeforeLoading = 10f;
    [SerializeField]
    private string scenenameload;
    private float timeElapsed;

    public void Update()
    {
    timeElapsed += Time.deltaTime;
    if (timeElapsed > DelayBeforeLoading)
    SceneManager.LoadScene(scenenameload);
    }

    }

    would appreciate either a link to documentation or better yet a tutorial on how to implement this or if it is an easy fix help with my script.

    thanks v much
    Nick