title: Unity3D Save or Load each Level and their own variables
body: <p>I am new to stackoverflow and  to Unity3D, so I am sorry if I am doing things wrong.</p>
  <p>So currently, I am making a puzzle game. It has 50 different levels.
  I need for each of them, to save 3 or 4 variables.
  For example, when level 1 is cleared, I want it to store (int)hitCounts, (bool)cleared, (int)bestHitCounts.
  I don't wanna use playerPrefs, as I don't want it to be readable from outside the box. I want it be converted to a binary file.
  here is what I have :</p>
  <p>#1 : made a static class TGameDat</p>
  <pre><code>[System.Serializable]
  public class TGameDat 
  {
      public int tGameDatInt;
      public bool tGameDatBool;
      public int tSceneIndex;
  
      public TGameDat (TPlayer player)
      {
          tGameDatInt = player.tInt;
          tGameDatBool = player.tBool;
          tSceneIndex = player.tScene;
      }
  }
  </code></pre>
  <p>#2 : then made Tplayer(monobehaviour)</p>
  <pre><code>
  
  public class TPlayer : MonoBehaviour
  {
      public int tInt = 0;
      public bool tBool = false;
      public int tScene;
      public List&lt;TPlayer&gt; TestGameDatList = new List&lt;TPlayer&gt;();
  
      private void Start()
      {
          TSceneMaker();
      }
  
      public void TSceneMaker()
      {
          tScene = SceneManager.GetActiveScene().buildIndex;
      }
  
      public void TNextScene()
      {
          SceneManager.LoadScene(tScene + 1);
      }
  
      public void TPreviousScene()
      {
          SceneManager.LoadScene(tScene - 1);
      }
  
      public void TSaveVariables()
      {
          TSave.TSavePlayer(this);
          TestGameDatList.Add(this);
          Debug.Log(&quot;saved&quot;);
          Debug.Log(tInt + &quot; &quot; + tBool + &quot; &quot; + tScene);
      }
  
      public void TLoadVariables()
      {
          List&lt;TGameDat&gt; data = TSave.TLoadPlayer(this);
          Debug.Log(&quot;loaded. data count = &quot; + data.Count + &quot; tSceneIndex &quot; + tScene);
  
                  tInt = data[0].tGameDatInt;
                  tBool = data[0].tGameDatBool;
                  tScene = data[0].tSceneIndex;
      }
  }
  </code></pre>
  <p>#3 : finally I created a save and load system :</p>
  <pre><code>
  public static class TSave
  {
      public static void TSavePlayer (TPlayer player)
      {
          BinaryFormatter formatter = new BinaryFormatter();
          List&lt;TGameDat&gt; data = new List&lt;TGameDat&gt;();
          string path = Application.persistentDataPath + &quot;/Tsave_&quot; + player.tScene + &quot;.fun&quot;;
  
          if(File.Exists(path))
          {
              FileStream stream = File.Open(path, FileMode.Open);
              data.Add(new TGameDat(player));
              formatter.Serialize(stream, data);
              stream.Close();
          }
          else
          {
              FileStream stream = File.Create(path);
              data.Add(new TGameDat(player));
              formatter.Serialize(stream, data);
              stream.Close();
          }
      }
  
      public static List&lt;TGameDat&gt; TLoadPlayer(TPlayer player)
      {
          string path = Application.persistentDataPath + &quot;/Tsave_&quot; + player.tScene + &quot;.fun&quot;;
          if(File.Exists(path))
          {
              BinaryFormatter formatter = new BinaryFormatter();
              FileStream stream = File.Open(path, FileMode.Open);
              List&lt;TGameDat&gt; data = new List&lt;TGameDat&gt;();
              
              data = formatter.Deserialize(stream) as List&lt;TGameDat&gt;;
              stream.Close();
              return data;
          }
          else
          {
              Debug.LogError(&quot;Save file not found in &quot; + path);
              return null;
          }
      }
  }
  
  </code></pre>
  <p>So, here are my problems :</p>
  <p>1 : in the current situation, each scene compiles a binary file. So at the end, it will have a bunch of binary files piled up... Like 50, as I have 50 scenes... isn't it too many?</p>
  <p>2 : of course I tried the make a single save file using List, and each level would come to add its own variable data in it.
  But instead of adding the data, it would simply replace the previous data. Then there is always only 1 index in the List.
  Therefore, when I load, the variables are from the last played level! And when I try to play another level after playing the first level, because there is only 1 index in the list, I get out of range error.</p>
  <p>How shall I approach this?
  sorry for the long long text!</p>
  <p>thank you for your inputs!</p>