小编Dan*_*iel的帖子

无法在iOS版Unity游戏中调用GameCenter

我试图将Game Center集成到我的Unity 5项目中,并且遇到了麻烦。似乎在iOS设备上启动游戏时,身份验证正常,出现通知,但页首横幅按钮不起作用,当我点击GC按钮时什么也没有发生。我将“ ShowLeaderboard()”的启动分配给了GC按钮。请看下面我使用的脚本。希望为我的问题找到解决方案。先感谢您。

using UnityEngine;
using UnityEngine.SocialPlatforms;
using UnityEngine.SocialPlatforms.GameCenter;
using System.Collections;

public class GameCenter : MonoBehaviour {

    public string leaderboardID = "mygameleaderboard";

    void Start () {
        AuthenticateToGameCenter();
    }

    private bool isAuthenticatedToGameCenter;
    public static void  AuthenticateToGameCenter() {
        #if UNITY_IPHONE
        Social.localUser.Authenticate(success => {
        if (success) {
            Debug.Log("Authentication successful");
        } else {
            Debug.Log("Authentication failed");
            }
        });
        #endif
    }

    public static void ReportScore(long score, string leaderboardID) {
        #if UNITY_IPHONE
        Debug.Log("Reporting score " + score + " on leaderboard " + leaderboardID);
        Social.ReportScore(score, leaderboardID, …
Run Code Online (Sandbox Code Playgroud)

c# game-engine unity-game-engine game-center-leaderboard unity5

2
推荐指数
1
解决办法
3230
查看次数