So I Upgraded from unity 5.3 to 5.6 now i got a new problem in my player script

Ok the problem is that whenever I want to use the UI text I need to convert my int values to string, so I made a method that simply took the Text variable and gave it the value of the Int variable I had so it could be used by the UI text object.

It looks like this:

void setText(Text textVar, int valueVar)
{

textVar.text = valueVar.ToString();

}

pretty simple right? well… im getting the error: NullReferenceException: Object reference not set to an instance of an object.

I am using the UnityEngine.UI library, its not based on an added script or component, its within the FPSController class, and it was working before I updated it, whats the problem? did something change regarding casting to strings or the text class? Any insights please, I dont seem to understand the problem at all.

Check that the Text control is still referenced in the inspector of your script

Are you sure that line is giving you the null error?

If so, then textVar would be null. But we’d have to see what script is calling it. Null has nothing to do with casting an int to a string nor is it anything with the text class. It means a variable is null and you are trying to use it while the value is null, so it can’t do what you want.