public void SaveAllInfoInBinary() { //List<GameObject> listOfGameObjToSave = listOfGameObj; for (int i = 0; i < listOfGameObj.Count; i++) { Info newInfo = new Info(); GameObject a = listOfGameObj[i]; Rigidbody rb = a.GetComponent <Rigidbody>(); Material mat = a.GetComponent <Material>(); newInfo.SetMyVelo(rb.velocity); newInfo.SetMyPos(a.transform.position); newInfo.SetMyAngularVelo(rb.angularVelocity); newInfo.SetMyRotation(a.transform.eulerAngles); newInfo.SetMyObjId(int.Parse(a.name)); // newInfo.SetMyColour(new Vector3(mat.color.r, mat.color.g, mat.color.b)); classToSerialize.myList.Add(newInfo); } string path = Application.dataPath + "/Resources/MyData.txt"; BinaryDataSaving.SaveDataToDisk(path, classToSerialize); }
public void SaveBinary() { for (int i = 0; i < allObjects.Count; i++) { Transform current = allObjects[i].transform; ObjectInfo info = new ObjectInfo(); info.SetPosition(current.position); info.SetRotation(current.eulerAngles); info.SetShapeId(int.Parse(current.name)); info.SetColor(current.GetComponent <MeshRenderer>().material.color); info.SetVelocity(current.GetComponent <Rigidbody>().velocity); info.SetAngularVelocity(current.GetComponent <Rigidbody>().angularVelocity); objSaveLoad.AddInfo(info); } BinaryDataSaving.SaveDataToDisk(fileName, objSaveLoad); }