Hi,
You are right. We call GetQuestion() on a QuestionSO object (not the script!), and that method returns something: a string. Since the computer cannot remember anything, we need to assign the returned string value to a variable, for example, questionText.text
. Otherwise, the string gets lost, and we would have to call the GetQuestion() again.
If you need a semi-real world example: The postman has a letter for you but since you do not have a postbox, he simply throws it into the dustbin. You call the post office asking where your letter is, and they send you another one which ends up in the dustbin again. Of course, you are not aware that this is happening, so you are waiting for the postman to complain. He has no clue what you are talking about and gives you the desired letter. However, whenever you are not waiting for the postman to receive the letter personally, you do not receive any letter. After some research on the internet, you learn that you need to install a postbox to receive letters without meeting the postman personally. You do that, and lo and behold, you suddenly receive letters as expected.
The same always happens in your C# code, not just in this specific game.
In C#, the dustbin is the so-called garbage collector. All data that do not have a place get destroyed. When receiving the data package, you need to decide immediately whether you process it directly or whether you assign it to a variable for later use. If you don’t do anything, the garbage collector takes care of it.
Hopefully, this cleared it up for you.
See also: