/// <summary> /// Takes a Unity Vector2 and converts it to a <see cref="SaveData.VectorData"/> format for serialization. /// </summary> /// <param name="vector"> A Unity Vector2.</param> /// <returns> <see cref="SaveData.TextureData"/> for serialization.</returns> public SaveData.VectorData VectorToSerializable(Vector2 vector) { SaveData.VectorData vectorToSave = new SaveData.VectorData(); vectorToSave.xcoord = vector.x; vectorToSave.ycoord = vector.y; return(vectorToSave); }
public void VectorSaveLoad() { Vector2 testVector = new Vector2(5, 5); SaveData.VectorData savedVector = PlayerData.instance.data.VectorToSerializable(testVector); Vector2 restoredVector = PlayerData.instance.data.SerializableToVector(savedVector); Assert.AreEqual(testVector, restoredVector); }
/// <summary> /// Takes a <see cref="SaveData.VectorData"/> and converts it to a Unity Texure2D for use in game. /// </summary> /// <param name="serializedVector"></param> /// <returns> A Unity Vector2 for use in game.</returns> public Vector2 SerializableToVector(SaveData.VectorData serializedVector) { Vector2 vectorToLoad = new Vector2(serializedVector.xcoord, serializedVector.ycoord); return(vectorToLoad); }