The question is answered, right answer was accepted
(Array) Is a 'field' but is used like a 'type'
So I'm trying to make a leaderboard system. I'm trying to get it to pull the playername which you enter into the textfield created after lives = 0, and pull count into a dictionary so that I can put that dictionary into a list, and have the list sort the dictionaries in score order. However, I'm currently stuck on the dictionary part. I just don't know what I'm doing wrong here, having looked up a few tutorials as well...
Here's the code:
using UnityEngine; using System.Collections; using System.Collections.Generic;
public class GUI_Button : MonoBehaviour {
public PlayerMovement GUIScript;
public RandomSpawn GUIScript1;
private int count = RandomSpawn.count;
public string PlayerName = "Enter name";
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<PlayerName, count> dictionary = new Dictionary<PlayerName, count> ();
}
}
}
The line generating the error is the last, with the error 'GUI_Button.PlayerName' is a 'field' but is used like a 'type'
Many thanks, Plumel
Answer by jebemti · Mar 17, 2016 at 10:40 PM
I've never really worked with Dictionaries but shouldn't
Dictionary<PlayerName, count> dictionary = new Dictionary<PlayerName, count> ();
be
Dictionary<string, int> dictionary = new Dictionary<string, int> ();