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
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