- Home /
X.Text just uses random values
I have some code, embedded below, and for some reason, Debug.Log(textNum) outputs the number I want, but Number.text doesn't use that number, even though I'm using literally the same variable. Does anyone have any insight?
string textNum = lastID.ToString();
Debug.Log(textNum);
Number.text = textNum;
Answer by FlaSh-G · Aug 06, 2017 at 09:34 AM
There's not really anything that could go wrong with this code, so I guess the problem lies elsewhere. Possible causes would be
Another line of code or another script is chaning
Number.text
as well.You have another instance of this script somewhere that overwrites
Number.text
.You have assigned the wrong object (or none) to
Number
.
My bets are on 2., but the others are possible too. Build a minimal example - a new scene with just the Text object and this script in it, then see what happens. Also look in the console for error messages and if your Debug.Log happens multiple times.
Your answer
Follow this Question
Related Questions
Text UI is not being assigned 2 Answers
NEW GUI SYSTEM - text with multiple values. 1 Answer
Add up updating float 2 Answers
Litjson autoformat 1 Answer