Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Is there a limit on the amount if values that you can save using playerprefs?

Discussion in 'Getting Started' started by Sylvir, Apr 28, 2015.

  1. Sylvir

    Sylvir

    Joined:
    Mar 21, 2015
    Posts:
    396
    i have been looking/watching videos and reading documentation today, but i am still unable to figure out if there is a limit on how many variables you can store under a playerprefs save. this is my code that im using.
    Code (CSharp):
    1.  
    2. public class Loading : MonoBehaviour {
    3.  
    4.     public GameObject saveButton;
    5.  
    6.     public static void LoadAllInformation()
    7.     {
    8.         GameControl.control.fish = PlayerPrefs.GetFloat ("TOTALFISH");
    9.         GameControl.control.fishPerClick = PlayerPrefs.GetFloat ("FISHPERCLICK");
    10.         GameControl.control.fishJewels = PlayerPrefs.GetFloat ("FISHJEWELS");
    11.         GameControl.control.currentExperience = PlayerPrefs.GetFloat ("CURRENTXP");
    12.         GameControl.control.fishingRank = PlayerPrefs.GetInt("FISHINGRANK");
    13.         GameControl.control.baseCost = PlayerPrefs.GetFloat ("BASECOST");
    14.         GameControl.control.cost = PlayerPrefs.GetInt("COST");
    15.         GameControl.control.clickPower = PlayerPrefs.GetFloat ("CLICKPOWER");
    16.         GameControl.control.count = PlayerPrefs.GetFloat ("COUNT");
    17.         GameControl.control.baseCostA = PlayerPrefs.GetFloat ("BASECOSTA");
    18.         GameControl.control.costA = PlayerPrefs.GetFloat ("COSTA");
    19.         GameControl.control.clickPowerA = PlayerPrefs.GetFloat("CLICKPOWERA");
    20.         GameControl.control.countA = PlayerPrefs.GetInt ("COUNTA");
    21.         GameControl.control.baseCostB = PlayerPrefs.GetFloat ("BASECOSTB");
    22.         GameControl.control.costB = PlayerPrefs.GetFloat ("COSTB");
    23.         GameControl.control.clickPowerB = PlayerPrefs.GetFloat("CLICKPOWERB");
    24.         GameControl.control.countB = PlayerPrefs.GetInt ("COUNTB");
    25.         GameControl.control.baseCostC = PlayerPrefs.GetFloat ("BASECOSTC");
    26.         GameControl.control.costC = PlayerPrefs.GetFloat ("COSTC");
    27.         GameControl.control.clickPowerC = PlayerPrefs.GetFloat("CLICKPOWERC");
    28.         GameControl.control.countC = PlayerPrefs.GetInt ("COUNTC");
    29.  
    30.     }
    31.  
    32.     public void OnClick()
    33.     {
    34.         LoadAllInformation ();
    35.         Debug.Log ("Information Loaded");
    36.     }
    37.  
    38.  
    39.  
    40.     // Use this for initialization
    41.     void Start ()
    42.     {
    43. //        LoadAllInformation ();
    44.     }
    45.    
    46.     // Update is called once per frame
    47.     void Update () {
    48.    
    49.     }
    50. }
    for the load, and then this for the save.
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Save: MonoBehaviour {
    5.  
    6.     public GameObject saveButton;
    7.  
    8.  
    9.     public static void SaveAllInformation()
    10.     {
    11.         PlayerPrefs.SetFloat ("TOTALFISH", GameControl.control.fish);
    12.         PlayerPrefs.SetFloat ("FISHPERCLICK", GameControl.control.fishPerClick);
    13.         PlayerPrefs.SetFloat ("FISHJEWELS", GameControl.control.fishJewels);
    14.         PlayerPrefs.SetFloat ("CURRENTXP", GameControl.control.currentExperience);
    15.         PlayerPrefs.SetInt ("FISHINGRANK", GameControl.control.fishingRank);
    16.         PlayerPrefs.SetFloat ("BASECOST", GameControl.control.baseCost);
    17.         PlayerPrefs.SetFloat ("COST", GameControl.control.cost);
    18.         PlayerPrefs.SetFloat ("CLICKPOWER", GameControl.control.clickPower);
    19.         PlayerPrefs.SetFloat ("COUNT", GameControl.control.count);
    20.         PlayerPrefs.SetFloat ("BASECOSTA", GameControl.control.baseCostA);
    21.         PlayerPrefs.SetFloat ("COSTA", GameControl.control.costA);
    22.         PlayerPrefs.SetFloat ("CLICKPOWERA", GameControl.control.clickPowerA);
    23.         PlayerPrefs.SetFloat ("COUNTA", GameControl.control.countA);
    24.         PlayerPrefs.SetFloat ("BASECOSTB", GameControl.control.baseCostB);
    25.         PlayerPrefs.SetFloat ("COSTB", GameControl.control.costB);
    26.         PlayerPrefs.SetFloat ("CLICKPOWERB", GameControl.control.clickPowerB);
    27.         PlayerPrefs.SetFloat ("COUNTB", GameControl.control.countB);
    28.         PlayerPrefs.SetFloat ("BASECOSTC", GameControl.control.baseCostC);
    29.         PlayerPrefs.SetFloat ("COSTC", GameControl.control.costC);
    30.         PlayerPrefs.SetFloat ("CLICKPOWERC", GameControl.control.clickPowerC);
    31.         PlayerPrefs.SetFloat ("COUNTC", GameControl.control.countC);
    32.  
    33.  
    34.                            
    35.     }
    36.  
    37.  
    38.     public void OnClick()
    39.     {
    40.         SaveAllInformation ();
    41.         Debug.Log ("Information Saved");
    42.     }
    43.  
    44.  
    45.     // Use this for initialization
    46.     void Start ()
    47.     {
    48.    
    49.     }
    50.    
    51.     // Update is called once per frame
    52.     void Update ()
    53.     {
    54.     //    SaveAllInformation ();
    55.     }
    56. }
    it seems to be saving and loading this much
    GameControl.control.fish = PlayerPrefs.GetFloat ("TOTALFISH");
    GameControl.control.fishPerClick = PlayerPrefs.GetFloat ("FISHPERCLICK");
    GameControl.control.fishJewels = PlayerPrefs.GetFloat ("FISHJEWELS");
    GameControl.control.currentExperience = PlayerPrefs.GetFloat ("CURRENTXP");
    GameControl.control.fishingRank = PlayerPrefs.GetInt("FISHINGRANK");
    GameControl.control.baseCost = PlayerPrefs.GetFloat ("BASECOST");
    GameControl.control.cost = PlayerPrefs.GetInt("COST");
    GameControl.control.clickPower = PlayerPrefs.GetFloat ("CLICKPOWER");
    GameControl.control.count = PlayerPrefs.GetFloat ("COUNT");
    but the rest seems to not be saving or loading. I can't seem to find if there is a limit on how many things you can save in the playerprefs save or not. that is my question, am i trying to save to many variables for playerprefs? thanks!
     
  2. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,965
    jhocking likes this.
  3. Sylvir

    Sylvir

    Joined:
    Mar 21, 2015
    Posts:
    396
    thanks ryiah, that is what i saw too, but it still wasn't seeming to save just wanted to make sure and confirm, i will mess around with it tomorrow and see what its doing with more debug logs and such. thanks!
     
  4. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,965
    Are you calling the Save function at some point? It should automatically do it at Application.Quit(), but if you're closing it with some other method, such as stopping it in the editor, it may not be doing it.

    Code (csharp):
    1. PlayerPrefs.Save();
     
  5. Sylvir

    Sylvir

    Joined:
    Mar 21, 2015
    Posts:
    396
    yeah, i have 2 buttons right now for testing one is to call the save function and one is to call the load function.