Answer the question
In order to leave comments, you need to log in
PlayerPrefs not working?
Here is how I save:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class Menu : MonoBehaviour
{
void Start()
{
if (!PlayerPrefs.HasKey("Sensitivity"))
{
PlayerPrefs.SetFloat("Sensitivity", 1f);
}
PlayerPrefs.Save();
}
public void OnSensChange(float value)
{
PlayerPrefs.SetFloat("Sensitivity", value);
PlayerPrefs.Save();
}
}
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class Player : MonoBehaviour
{
private float Sensitivity;
private void Awake()
{
Sensitivity = PlayerPrefs.GetFloat("Sensitivity");
PlayerPrefs.Save();
}
}
Answer the question
In order to leave comments, you need to log in
!PlayerPrefs.HasKey("Sensitivity") - in this case, there may be a jamb, because if you've ever written a value to PlayerPrefs (in a previous run), it will be there. Therefore, some values may not be saved.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question