public posSave(testSaving player) { posOfCam = new float[3]; posOfCam[0] = player.transform.position.x; posOfCam[1] = player.transform.position.y; posOfCam[2] = player.transform.position.z; }
public static void savePosOfCam(testSaving player) { BinaryFormatter formatter = new BinaryFormatter(); //string path = Application.persistentDataPath + "/player.save"; string path = Application.persistentDataPath + "/player.save"; FileStream stream = new FileStream(path, FileMode.Create); posSave data = new posSave(player); formatter.Serialize(stream, data); stream.Close(); }
public static void savePosOfBuilding(testSaving Cam) { //greates the encrypter BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/buildingPos.save"; FileStream stream = new FileStream(path, FileMode.Create); //send the dater further in the system savingBuildPos data = new savingBuildPos(Cam); //encrypt the data formatter.Serialize(stream, data); stream.Close(); }
//this is an public class remember public savingBuildPos(testSaving Cam) { posOfBuildingX = new float[Cam.buildingsName.Count]; posOfBuildingY = new float[Cam.buildingsName.Count]; buildingsNames = new string[Cam.buildingsName.Count]; // goes trough every num or string in the array/list for (int i = 0; i < Cam.buildingsName.Count; i++) { posOfBuildingX[i] = Cam.buildingsPosX[i]; posOfBuildingY[i] = Cam.buildingsPosY[i]; buildingsNames[i] = Cam.buildingsName[i]; } }