Hacker Terminal example

Here is my Terminal screen.

And I have a question. In order to put more characters in the string, I changed the variables:

 [SerializeField]  int charactersWide = 80;
 [SerializeField]  int charactersHigh = 20;

But nothing changed on screen. And it started to work right only when I wrote it like this:

[SerializeField] readonly int charactersWide = 80;
[SerializeField] readonly int charactersHigh = 20;

This means that these variables are calculated somewhere. But I can’t understand where. Could you help me with this issue?

Hi,

[SerializeField] exposes a variable in your Inspector. The Inspector will override the value in your code. So if you change the value in your code, nothing will happen.

The second version might have worked because of the readonly keyword which prevents the value from being overridden.

Is this what you wanted to know?

Hi Nina,

Thanks for your reply. OK, now I understand, what these parameters overrided by Inspector. But this is not “public” variable, so I can’t see it (and can’t change it) in Inspector. But it’s calculated in some way. And I want to understand, from what data and with which algorithm it’s calculated.

OK, solved. If I remove “readonly”, variables appears in Inspector.

Thank you!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.