public void LoadGame() { if (!File.Exists(filePath)) { return; } BinaryFormatter bf = new BinaryFormatter(); //open file for write varibale FileStream fs = new FileStream(filePath, FileMode.Open); Save save = (Save)bf.Deserialize(fs); Tuning tuning = GetComponent <Tuning>(); CarSpawnerTest carSpawn = GetComponent <CarSpawnerTest>(); if (tuning) { tuning.LoadData(save); } if (carSpawn) { carSpawn.LoadData(save); } //close file fs.Close(); }