Unity сохраняет не все данные
Делаю кликер и столкнулся с такой проблемой. При Сохранении данных через PlayerPrefs сохраняется только score а остальное нет. Заранее спасибо за помощь. Код:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class But : MonoBehaviour{
public int score;
public int scoreAdd;
public float lvFloat;
public float lvAdd;
public int lv;
public int priceLv = 150;
public Text clickText;
public Text sliderText;
public Text LvPrice;
public Slider slider;
public Button butLv;
public Animator butLvAni;
public GameObject effect;
void Start(){
if (!PlayerPrefs.HasKey("Score")){
PlayerPrefs.SetInt("Score", 0);
PlayerPrefs.SetInt("ScoreAdd", 1);
PlayerPrefs.SetFloat("lvFloat", 0);
PlayerPrefs.SetInt("lv", 1);
PlayerPrefs.SetFloat("lvAdd", 0.01f);
PlayerPrefs.SetInt("priceLv", priceLv);
}
score = PlayerPrefs.GetInt("Score");
scoreAdd = PlayerPrefs.GetInt("ScoreAdd");
lvFloat = PlayerPrefs.GetFloat("lvFloat");
lv = PlayerPrefs.GetInt("lv");
lvAdd = PlayerPrefs.GetFloat("lvAdd");
priceLv = PlayerPrefs.GetInt("priceLv");
}
void Update(){
if(lvFloat >= 1){
butLv.interactable = true;
butLvAni.SetBool("lvUp", true);
LvPrice.text = priceLv.ToString() + "$";
}
clickText.text = score.ToString() + "$";
slider.value = lvFloat;
sliderText.text = lv.ToString() + "lv";
}
public void Click(){
Instantiate(effect, transform.position, Quaternion.identity);
score+=scoreAdd;
PlayerPrefs.SetInt("Score", score);
if( lvFloat < 1 ){
lvFloat += lvAdd;
PlayerPrefs.SetInt("lvFloat", score);
}
}
}