- Home /
The variable has not been assigned
Hello! I've read the forum but still cannot find the solution. I have the following error in my code
"UnassignedReferenceException: The variable borderLeft of FoodController has not been assigned. You probably need to assign the borderLeft variable of the FoodController script in the inspector. UnityEngine.Transform.get_position () (at C:/buildslave/unity/build/artifacts/generated/common/runtime/TransformBindings.gen.cs:27) FoodController.Spawn () (at Assets/FoodController.cs:25)"
I initialize this variable like - public Transform borderLeft;
And than I try to get x position - borderLeft.position.x;
In Unity editor everything is also according to the rules
How can I solve this trouble?
Are you assigning borderLeft from somewhere else in the script?
Can you show us your script (or script part with the relevant code)?
If you remove borderLeft will the error re-appear with one of the other variables?
Your answer
Follow this Question
Related Questions
Variables to represent the edges of the screen 1 Answer
Dropdown selection in inspector. 0 Answers
how to access a custom editor's public variables? 1 Answer
How to dynamically create variable names? 1 Answer
convert javascript to c# 0 Answers