Пример #1
0
    IEnumerator CheckForGaze()
    {
        while (Application.isPlaying)
        {
            yield return(new WaitForSeconds(.15f));

            if (lastIsOver != item.IsOver)
            {
                if (item.IsOver && !audioSource.isPlaying)
                {
                    audioSource.clip = SoundToPlay;
                    audioSource.Play();

                    lastStartTime = Time.time;
                    canActivate   = true;
                }
                else
                if (!item.IsOver && audioSource.isPlaying)
                {
                    audioSource.Stop();
                    uiSelectionBar.fillAmount = 0;
                }
            }

            if (item.IsOver)
            {
                lastIsOver = true;

                if (lastStartTime > 0 && ((lastStartTime + ActivationTime) <= Time.time))
                {
                    if (canActivate)
                    {
                        lastStartTime = 0;
                        canActivate   = false;
                        StartCoroutine(btn.ActivateButton());
                    }
                }
            }
            else
            {
                lastIsOver                = false;
                canActivate               = true;
                lastStartTime             = 0;
                uiSelectionBar.fillAmount = 0;
            }
        }
        yield return(null);
    }