public LastEnemyV2Data(LastEnemyV2 enemy) { level = enemy.level; health = enemy.health; position = new float[3]; position[0] = enemy.transform.position.x; position[1] = enemy.transform.position.y; position[2] = enemy.transform.position.z; }
public static void SaveLastEnemyV2(LastEnemyV2 enemy) { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "lastEnemyV2.fun"; FileStream stream = new FileStream(path, FileMode.Create); LastEnemyV2Data data = new LastEnemyV2Data(enemy); formatter.Serialize(stream, data); stream.Close(); }