1

I am trying to create a timed progress bar that fills over time. This is the script that I created and attached to my fill image. When I run the game I get an error saying "Object reference not set to an instance of an object".

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

    public class timerFill : MonoBehaviour
    {

        public Image fill;

        // Start is called before the first frame update
        void Start()
        {

        }

        // Update is called once per frame
        void Update()
        {
            fill.fillAmount += Time.deltaTime / 100;
        }
    }
Ruzihm
  • 19,749
  • 5
  • 36
  • 48
  • You're not instantiating the ```Image``` – Jabberwocky Jan 19 '20 at 20:25
  • @Jabberwocky assigning or initializing ;) – derHugo Jan 20 '20 at 06:14
  • I just needed to assign the fill Image in the inspector. I am really new to unity so I had no idea you had to do that. It's unfortunate that this was closed out by people who don't even use Unity before someone could actually answer it. I won't be including the C# tag if I have any more questions lol. – Gino Cinquanti Jan 20 '20 at 21:38
  • This question has nothing to do with [tag:unityscript] – Ruzihm Jan 24 '20 at 19:51

0 Answers0