How do I increase an integer??

public int TestInt;

public void Update()
    {
        TestInt += 1;
    }

This should increase TestInt by 1 every frame, right? But in the inspector, it stays at zero :frowning:
Am I doing something incorrectly? Do I have a misunderstanding of how the inspector works?

EDIT: I found the issue. My script was attached to a prefab rather than a gameobject. Like an idiot, I was looking at the value of the int by inspecting the prefab rather than the gameobject created when the prefab was initialized.

Edit2: and I resolved the issue be storing the int as a value in another script attached to another gameobject, then copying those values to the prefab upon initialization. Hope this helps somebody.

You could do

TestInt ++;

This should work just fine. Just make sure you don’t have the edit field in the inspector selected. When you select / click into the edit field the current value is copied into the string editor. Since you can now edit the value it isn’t updated anymore until the field is deselected.

Okay so actually it does work if I put it on a new script. I just can’t increase (or change at all, it seems) the identically coded integers in my own script.