// Initialization---------------------------------------------------------- void Start() { pr = GameObject.Find("Player").GetComponent <PlayerRecording>(); localRotationPoints = pr.CreateCopyRotationList(); localRecordedPoints = pr.CreateCopyPointList(); StartCoroutine("Movement"); }
public void Save() { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Create(Application.persistentDataPath + "/playerSave.dat"); PlayerRecording data = new PlayerRecording(); data.jumpTick = currentPlayerJumpTick; data.leftTick = currentPlayerLeftTick; data.rightTick = currentPlayerRightTick; bf.Serialize(file, data); file.Close(); }
public void Load() { if (File.Exists(Application.persistentDataPath + "/playerSave.dat")) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/playerSave.dat", FileMode.Open); PlayerRecording data = (PlayerRecording)bf.Deserialize(file); file.Close(); GameObject shadow = Instantiate(shadowPrefab, new Vector3(2.77f, 1.84f), Quaternion.identity) as GameObject; PlayerControllerScript script = shadow.GetComponent <PlayerControllerScript>(); script.recorded = true; script.jumpTick = new List <int>(data.jumpTick); script.leftTick = new List <int>(data.leftTick); script.rightTick = new List <int>(data.rightTick); } }