public void SaveGame() { MyPlayer ply = new MyPlayer(); ply.SetDomain(SceneManager.GetActiveScene().buildIndex); BinaryFormatter bf = new BinaryFormatter(); FileStream fl = File.Create(Application.persistentDataPath + "/player.dat"); bf.Serialize(fl, ply); fl.Close(); }