- Home /
Question by
RehanSanish · Nov 27, 2021 at 02:43 AM ·
save dataint
Unity not resetting int value save
For some reason, Unity is not saving the int value when it is reset. I need help fixing it.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameManager : MonoBehaviour
{
public static int DELUXE;
public static int multiplier;
public void Start()
{
multiplier = PlayerPrefs.GetInt("multiplier", 1);
DELUXE = PlayerPrefs.GetInt("DELUXE", 0);
}
private void Update()
{
Reset();
}
void Reset()
{
if (Input.GetKeyDown(KeyCode.R))
{
DELUXE = 0;
multiplier = 1;
}
}
}
Comment
Answer by PharmacyBrain · Nov 27, 2021 at 02:47 AM
All you're doing is reading values from player prefs. You're changing the value of a variable at runtime and never actually writing the new values to player prefs.
So how do I change the variables permanently? And how do I make it saved?
Your answer
Follow this Question
Related Questions
Need help yielding during AsyncOperations with my function being called as an int 0 Answers
playerprefs 0 Answers
will switching scenes overwrite data? 2 Answers
Convert float to int without Math.Round? 2 Answers
Convert Array to String 3 Answers