Filling Bar (Slider) while looking at one gameObject (VR)

Hi guys,

I followed this tutorial:

Where basically you can fill a bar (Slider) looking at it (in VR).

What I want to do is fill the bar looking other gameObject not the bar. And if you are not looking any object the bar will be disabled. I could do this last. but not loading the bar.

This is my code:

CODE FROM YOUTUBE (In Update is the code to enable or disable the slider if you are looking at it or not.

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

namespace piedrapapeltijera
{
    public class sliderLookatACtion : MonoBehaviour
    {
        public Canvas slider;
        public float fillTime = 1.5f;
        private float timer;
        private bool gazedAt;
        private Coroutine fillBarRoutine;

        private Slider mySlider;

        // Use this for initialization
        void Start()
        {
            mySlider = GetComponent<Slider>();
            if (mySlider == null)
            {
                Debug.Log("No Slider Found¡¡¡");
            }

            slider.enabled = true;
        }

        // Update is called once per frame
        void Update()
        {
            if (reticle.paperSelected == true || reticle.rockSelected == true || reticle.scissorSelected == true )
            {
                slider.enabled = true;
            }
            else
            {
                slider.enabled = false;
            }
        }
        public void PointerEnter()
        {
            Debug.Log("FUNCIONA¡");
            gazedAt = true;
            fillBarRoutine = StartCoroutine(FillBar());
        }
        public void PointerExit()
        {
            gazedAt = false;
            if (fillBarRoutine != null)
            {
                StopCoroutine(fillBarRoutine);
            }

            timer = 0f;
            mySlider.value = 0f;
        }
        private IEnumerator FillBar()
        {
            timer = 0f;
            while (timer < fillTime)
            {
                timer += Time.deltaTime;
                mySlider.value = timer / fillTime;
                yield return null;

                if (gazedAt)
                    continue;
                timer = 0f;
                mySlider.value = 0f;

                yield break;
            }
            OnBarFilled();
        }

        private void OnBarFilled()
        {
            //Hacer lo que sea
            Debug.Log("WORKS");          
        }
    }
}

OK, I done it…

I followed other tutorial from the same person…

And mixing the code and functions I could do it…

I think my problem was that I didnt have a Physic Raycaster attached to the camera, and I used the default reticle by Google. Doing that my problem was solved.