Hi,
I want the code to write PlayerNameFinal and count to an array in leaderboard.txt when SaveScoreButton is pressed.
This is currently what is being written to the file: System.Collections.Generic.Dictionary`2[System.String,System.Int32]
Code:
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";
string[] PlayerAndScore = new string [1];
public string PlayerNameFinal;
public string count1 = "";
private bool SaveScoreButton = false;
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);
SaveScoreButton = GUI.Button (new Rect (400, 500, 200, 100), "Save Score");
CountToString ();
}
}
void OnClick()
{
PlayerNameFinal = PlayerName;
}
void Start()
{
PlayerAndScore [0] = PlayerNameFinal;
PlayerAndScore [1] = count1;
System.IO.File.WriteAllLines(@"Desktop\Pixel Ninjav3.3\Assets\leaderboard.txt", PlayerAndScore);
}
void CountToString ()
{
count1 = count.ToString();
}
}