I get this error message in the following line but I don't know what I'm doing wrong.
Scorelist.Add(entry.StatValue);
Error CS0120: An object reference is required for the non-static field, method, or property 'Game1.Scorelist'
How can I fix the issue?
public List<int> Scorelist = new List<int>();
NewClient();
public async void NewClient()
{
await DoReadLeaderboard();
}
private static async Task DoReadLeaderboard()
{
// Get Leaderboard Request
var result = await PlayFabClientAPI.GetLeaderboardAsync(new GetLeaderboardRequest()
{
// Specify your statistic name here
StatisticName = "TestScore",
// Override Player Profile View Constraints and fetch player DisplayName and AvatarUrl
ProfileConstraints = new PlayerProfileViewConstraints()
{
ShowDisplayName = true,
ShowAvatarUrl = true
}
});
if (result.Error != null)
{
// Handle error if any
Console.WriteLine(result.Error.GenerateErrorReport());
}
else
{
// Traverse the leaderboard list
foreach (var entry in result.Result.Leaderboard)
{
Scorelist.Add(entry.StatValue);
}
}
}