Can Vexe.FastSave save dictionaries to files?

I’m trying to get two variables in the dictionary, PlayerName and count to be saved in an array in the file so that I can sort the file and have it in score order and have the names relevant to the score.

I’ve just come across the Vexe plugin and have only seen examples of it saving gameobjects.

Anyone know?

@vexe pls :slight_smile:

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using Vexe.FastSave;
using Vexe.Runtime.Types;

public class GUI_Button : MonoBehaviour {

public PlayerMovement GUIScript;
public RandomSpawn GUIScript1;
private int count = RandomSpawn.count;
public string PlayerName = "Enter name";
public string fileName = "leaderboard.txt";

[show] void OnGUI ()
{
	if (PlayerMovement.livess <= 0) 
	{
		GUI.Button (new Rect (400, 200, 300, 200), "Score:" + (count+10));
		PlayerName = GUI.TextField (new Rect (400, 400, 300, 100), PlayerName);
		Dictionary<string, int> dictionary = new Dictionary<string, int> ();
		string dictPath { Get { return Application.dataPath + "/" + fileName; } };
		dictionary.Add (PlayerName, count);
	}
}
[show] void Save()
{
	Save.DictionaryToFile(
		Application.dataPath + "Plum/Desktop/Pixel Ninjav3.3/Assets/leaderboard", target);
}

}

Thanks in advance

It’s been a while, but IIRC you need to add a strongly-typed dictionary serializer, so you say FSCommon.Serializer.AddStrongDictionary(…) and then you could say Save.ObjectToFile(…) and it should pick up that dictionary serializer you specified if you pass it the same dictionary type with the generic parameters you specified in that AddStringDictionary function. I can’t remember exactly how you do it but I think you just say

var dictSer = new DictionarySerializer<string, int>();
FSCommon.Serializer.AddStrongDictionary(dictSer.StrongSerialize, dictSer.StrongDeserialize);
Save.ObjectToFile(...);