0

So I was trying to make a countdown timer from my parent class only and it is working properly but in the update console it's flooding with "Object referrence not set an instance of an object" so I was hoping if there is some way to fix this? here is my code

Tried the Serialize Field but still no

 [SerializeField] private TextMeshProUGUI countdownTimer;
   void Start()
   {
      currentTime = startingTime * Time.deltaTime;
   }

   void Update()
   {
    currentTime -= 1;
    countdownTimer.text = currentTime.ToString("0");
   }

so Here is my child class

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

 public class BroadScript : GameManagerRevamped
 {
  public override void rightanswersButton()
  {
    base.rightanswersButton();
}


public override void Shuffler()
{
    ShuffleCounter += 1;
    base.Shuffler();
}
public override void firstButtonClicked()
{
    ClicksCounter += 1;
    finalAnswer += "b";
    base.firstButtonClicked();
}

public override void secondButtonClicked()
{
    ClicksCounter += 1;
    finalAnswer += "r";
    base.secondButtonClicked();
}

public override void thirdButtonClicked()
{
    ClicksCounter += 1;
    finalAnswer += "o";
    base.thirdButtonClicked();
}

public override void fourthButtonClicked()
{
    ClicksCounter += 1;
    finalAnswer += "a";
    base.fourthButtonClicked();
}

public override void fifthButtonClicked()
{
    ClicksCounter += 1;
    finalAnswer += "d";
    base.fifthButtonClicked();
}

}

I was able to get the function properly but the error is just flooding.

  • 1
    You need give a instance of `TextMeshProUGUI` to `countdownTimer` property, drag one from the Hierachy window or set it with the script. – shingo Feb 16 '19 at 12:26
  • 1
    Thus I can't understand the word _parent_, _child_ and _properly_ in your question, there is only one class and it must not work because of the exception, please review the question again. – shingo Feb 16 '19 at 12:30
  • I already added one instance in the parent class but the error is still flooding – Nicole Erasga Feb 16 '19 at 12:34
  • 1
    This is a null reference exception... – Immersive Feb 16 '19 at 13:48
  • Please show the *entire class* rather than just this snippet. We can't solve your problem without all of the necessary information. – Draco18s no longer trusts SE Feb 16 '19 at 19:26
  • all child classes are like that with jsut different values that is! :) – Nicole Erasga Feb 16 '19 at 19:37
  • Possible duplicate of [What is a NullReferenceException, and how do I fix it?](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – Eliasar Feb 18 '19 at 19:21

0 Answers0