- Home /
Question by
Gehrman3 · May 09, 2017 at 06:13 AM ·
playerprefsgoogle playleaderboardleaderboardslong
Google Play Leaderboard help
I try to use leaderboards in my game but I cant use long. I see this error.
Assets/Scripts/HS2.cs(32,10): error CS1502: The best overloaded method match for `UnityEngine.Social.ReportScore(long, string, System.Action)' has some invalid arguments
How can I fix this
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class HS2 : MonoBehaviour {
public Text highScoreText;
public float highScoreCount;
public GameObject highScore;
private ScoreManager theScoreManager;
// Use this for initialization
void Start () {
theScoreManager = FindObjectOfType<ScoreManager> ();
if (PlayerPrefs.GetFloat ("hs1") != null) {
highScoreCount = PlayerPrefs.GetFloat ("hs1");
}
}
// Update is called once per frame
void Update () {
if (theScoreManager.scoreCount > highScoreCount) {
highScoreCount = theScoreManager.scoreCount;
PlayerPrefs.SetFloat ("hs1", highScoreCount);
}
highScoreText.text = "" + Mathf.Round (highScoreCount);
Social.ReportScore (highScoreCount, rot.leaderboard_normal_mode, (bool success) => {
});
}
}
Comment
Just cast highScoreCount to long
Social.ReportScore ((long) highScoreCount, rot.leaderboard_normal_mode, (bool success) => {
});