【问题标题】:Issues with Syntax in Unity and Google Play ServicesUnity 和 Google Play 服务中的语法问题
【发布时间】:2016-03-06 07:27:49
【问题描述】:

我正在制作一个脚本来使用 Google Play 服务函数,我刚刚导入了所有内容并准备就绪,但出于某种原因,Unity 不喜欢 Google 告诉我在函数末尾使用的语法});。我试图找出解决方案没有运气,绝望中我来到这里看看是否有人知道它。任何回复都非常感谢!

using UnityEngine;
using System.Collections;
using GooglePlayGames;
using UnityEngine.SocialPlatforms;

public class Destroy : MonoBehaviour {

    public GameObject Player;

    // Update is called once per frame
    void OnTriggerEnter2D(Collider2D other) {
        if(other.gameObject.tag == "Player") {
            DestroyObject(other.gameObject);
            Jumping.Dead = true;
            if (Points.BestScore >= PlayerPrefs.GetInt("BestScore")) {
                PlayerPrefs.SetInt("BestScore", Points.BestScore);
            }
            Application.LoadLevel(Application.loadedLevel);
        }
    }

    public void ReportToLeaderboard() {
        Social.ReportScore(PlayerPrefs.GetInt("BestScore")), "taken out for obvious reasons", (bool success) => {
                // Score Reported
        });
    }
}

这里是我获取源代码的地方: https://github.com/playgameservices/play-games-plugin-for-unity

这是 Unity 错误:

Assets/Scripts/Destroy.cs(23,68): error CS1525: Unexpected symbol `,', expecting`;'

【问题讨论】:

    标签: c# android unity3d google-play-services


    【解决方案1】:

    您遇到错误是因为您在 Social.ReportScore(PlayerPrefs.GetInt("BestScore")**)** 中有额外的“)

    这应该可以解决它

    public void ReportToLeaderboard()
    {
        Social.ReportScore(PlayerPrefs.GetInt("BestScore"), "taken out for obvious reasons", (bool success) =>
        {
            // Score Reported
        });
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多