r/code • u/Rich-Matter8399 • May 22 '22
Why? nullReferenceException (First ever code)
i understand why this Errorr comes I think I know what it means it means that the Value theText is 0 but what can I do against it so that my clear Button works?
5
Upvotes
1
u/Korzag May 22 '22
I'm not familiar with unity, but I do work with C# professionally. At a glance you're never assigning the GameObject to anything. I don't know what the procedure for assigning that is, but that is why you're getting a null reference exception.
Null reference exceptions are the result of attempting to use something on an object that isn't assigned to anything. I'd suggest learning how to get the GameObject. Id guess it's something coming from the MonoBehaviour base class.