Saving an integer within a scene

So I am making a beat saber clone, and I recently messed around with Text Meshes so I can display data, Misses, Hits etc. But I need a way to save the integer, within the scene, therefore it should reset everytime, I’ve tried multiple things, I just can’t figure it out. All I need is a method, to, Add 1 to the integer, and one to get the integer, which should be fairly easy, I just need it to be able to be accessed from both my saber script, to add one, and the object my text is in, so I can update it. Thanks!

bump?

It’s really unclear what you’re asking for. What does saving the integer within the scene mean? Are you looking for a save/load game system?

No, i’m trying to save a data value that resets within a scene, just like how when you reload a scene it resets, thats it, nothing more, just a save an load systen for one variable, not a scene saving / load system

I’m just used to doing this in java, but apparently it’s not like that in Unity

public int misses = 0;

public void add(int i) {
    misses += i;
}

public int getValue() {
    return misses;
}

[quote=“PraetorBlue, post:3, topic: 800270, username:PraetorBlue”]
What does saving the integer within the scene mean?
[/quote] Well I mean, saving, an integer variable… Within a scene, an integer is a whole number

That code would work fine in C# too, it just depends on the lifecycle of the GameObject it’s attached to. If it’s attached to an object in a scene hierarchy it will work fine. If it’s a prefab or ScriptableObject, it won’t.