public class LevelPrefs : MonoBehaviour
{
public Transform playerPrefRef;
public Text textPrefRef;
int lvlTextInt = 1;
bool incrementBool = true;
int i;
private void Start()
{
incrementBool = true;
if (playerPrefRef.position.z <= -86 && incrementBool)
{
PlayerPrefs.SetInt("Current Int", lvlTextInt += 1);
incrementBool = false;
//lvlTextInt++;
}
}
private void Update()
{
textPrefRef.text = PlayerPrefs.GetInt("Current Int", lvlTextInt).ToString();
}
void playerPrefsMeth()
{
PlayerPrefs.SetInt("Current Int", lvlTextInt);
}
public void resetPrefs()
{
PlayerPrefs.DeleteKey("Current Int");
}
}
it at first the level of the game is 1 then after it reaches the end the int becomes 2 but afterwards it doesn’t increment at all if you play the game again or keep playing because after you reach the finish line it resets and it starts with 2 now but when it finishes it doesn’t becomes 3 or stack up.