UnassignedReferenceException

I don’t know what’s happening and I am getting very mad because it’s basic.
I am getting this error:

You probably need to assign the Text variable of the CongratScript script in the inspector.
CongratScript.Start () (at Assets/CongratScript.cs:28)```

I don't understand it because seems to me that the variable was assigned

![](https://forum.unity.com/attachments/imagem_2023-07-06_023446443-png.1266919/?temp_hash=eafc2cd765e8c3b934afe76d77732ac7)

Btw I am using unity 2022.3.4f1. I not sure if it is a bug or I am just stupid

![9127774--1266919--imagem_2023-07-06_023446443.png|802x638](upload://kVjsL6iE4wbHnvOa6ix4hda4RKQ.png)
[9127774--1266922--CongratScript.cs|attachment](upload://tQJwoImvoglwVcuCuN04bDezgUw.cs) (1.17 KB)

If I guess correctly, your script Text reference is to a prefab and not to your scene object. Reassign it by dragging your TextDisplay scene object to the field.

The answer is always the same… ALWAYS!

How to fix a NullReferenceException error

https://forum.unity.com/threads/how-to-fix-a-nullreferenceexception-error.1230297/

Three steps to success:

  • Identify what is null ← any other action taken before this step is WASTED TIME
  • Identify why it is null
  • Fix that

It is not a NullReferenceException but an unassigned reference that appears to be assigned.

UnassignedReferenceException is just a wrapper Unity adds to give you more information.

This is explicitly stated in my link.

9128995--1267291--Screen Shot 2023-07-06 at 6.51.46 AM.png

It’s still functionally just a nullref.

And the answer is still the same.

That just means you didn’t find the one that was null. You’re still on Step #1 - Identify what is null

How to fix a NullReferenceException error

https://forum.unity.com/threads/how-to-fix-a-nullreferenceexception-error.1230297/

Three steps to success:

  • Identify what is null ← any other action taken before this step is WASTED TIME
  • Identify why it is null
  • Fix that

No, it is an unassigned reference, and if you take this information and look at his output, you’ll see that the Text reference is unassigned yet in his editor screenshot it appears assigned. So we have clearly identified what is null, and trying to understand why it is null.

No, you haven’t identified what is null.

What you have above might be non-null. GREAT!

That just means you didn’t find the one that is null. Did the script get inadvertently dragged onto some other GameObject where it isn’t set up?

Or was that property null at the time it was accessed, but now it is okay?

ALL of these things are stuff I see every day, almost every hour. So just keep at it.

THAT is null on CongratScript.cs:28.
9129304--1267339--upload_2023-7-6_16-46-25.png

Still unaddressed is this issue:

There’s only four GameObjects in the scene. Make sure another doesn’t have this script as well. This happens ALL THE TIME… you drag a script into the scene and miss the target. You re-drag it. Congratulations. Now you have two CongratScripts.

The computer is never wrong with these, regardless of how much you post about it or how “very mad” you get about it.

1 Like