Code bug or personal screwup?



999,999 times out of a million mistakes are on the user not the program, but I’m a bit frustrated at hitting what seems to be a wall. I’ve a project where I assign a Serialized Field TextMeshPro for an integer (in this case attackLevelText) just like a dozen other times. But what I get in game and in Unity is a zero where I’d expected a one.

Fine, seems a job for Debug.Log, but everywhere in my code that I can find, the source is coming up as one. Finally I dropped a couple of Debug lines on the code where the field is set. Still getting a one for the value I’m setting the text to, and a zero for the text.

I don’t see how this could be possible. A search confirms that the text line only appears four times in my project: where it is serialized, an assert.isnotnull, where it is assigned, and the debug call. So it shouldn’t be able to change from the one that the value should be setting it at.

attackLevelText.text = Character.AttackLevel.Value.ToString();

Debug.Log(Character.AttackLevel.Value.ToString()+" is the BCV value");
Debug.Log(attackLevelText.text + " is the level text?");

1 is the BCV value
Scratch.BoardCharacterView:OnMouseDown() (at Assets/Scripts/BoardCharacterView.cs:97)

0 is the level text?
Scratch.BoardCharacterView:OnMouseDown() (at Assets/Scripts/BoardCharacterView.cs:98)

Here’s a link to a pic of the whole thing, can see the debug in the left, the code top center and the search showing the four places the text is referenced.

I feel like I’ve had some issues with the modulo function % not work correctly, is there some bug that causes integers to get screwy? If so are there any known workarounds? Seems like something that would be an issue.



In which course and which lecture are you? Do you still need help with this issue?

automatically bumped #3

closed #4