2016-07-17 4 views
0

이 질문을 입력하기 전에이 문제에 2 주간 붙어서 많이 검색했습니다. '() 에 설명 된대로Unity Android 게임 Google Play 게임 플러그인을 사용하여 로그인 할 수 있지만 리더 보드에서 점수를로드 할 수 없음

1 통합 구글 플레이 게임 플러그인 :. 내 유니티 프로젝트에서 구글 리더 기능이 나는 다음과 같은 단계를 따라 https://github.com/playgameservices/play-games-plugin-for-unity

  • 만든 내 구글 플레이 개발자 콘솔에서 구글 플레이 서비스 게임 항목 및 오픈 아이디의 com.o6systems.zray 패키지 아이디와 함께 (같은 콘솔에있는) 내 애플리케이션에 연결하십시오. pha 테스트.
  • 크레딧을 생성하고 키 스토어/키 쌍의 SHA1을 Google API 콘솔에 삽입했습니다.
  • 나는 도전 과제, 1 개 점수 판을 만들어 내 자원은 창/GooglePlayGames/설정/안드로이드 설정

내가 사용하는 키 스토어는 SHA1 코드를 생성하는 동일에 입력하세요. 플레이어 설정과 암호에 입력했습니다.

내 패키지 이름은 내가 콘솔에서 테스트 사용자에게 내 테스트 사용자를 입력

(구글 사방 연합, Play 개발자 콘솔 구글 API를 콘솔에서) 모든 플랫폼에서 일치한다.

void Start() { 
     #if UNITY_ANDROID 
     ConfigureGooglePlay(); 
     SignIn(); 
     #endif 
} 

void ConfigureGooglePlay(){ 

      PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder() 
       .Build(); 
      PlayGamesPlatform.InitializeInstance(config); 
     PlayGamesPlatform.DebugLogEnabled = true; 
     PlayGamesPlatform.Activate(); 
} 

void SignIn() { 
     Social.localUser.Authenticate (success => { 
      if (success) { 
       Debug.Log ("Authentication successful"); 
       string userInfo = "Username: " + Social.localUser.userName + 
            "\nUser ID: " + Social.localUser.id + 
            "\nIsUnderage: " + Social.localUser.underage; 
       Debug.Log (userInfo); 

      // DisplayGPScore(); 
      } else 
       Debug.Log ("Authentication failed"); 
     }); 
    } 

3- 게임 장면에서, 게임에 내가 리더에 사용자의 높은 점수를 게시 이상 : 스크립트 내되는 SplashScreen 현장에서 작업의

2

나는 하나의 인증을 위해 다음과 같은 코드를 입력 ReportScore 기능

private void OnGameOver(){ 
     ... 
     PostScore(_gm.highScore); 
     .. 

     DisplayGPScore(); 
    } 

    internal void LoadUsersAndDisplay(ILeaderboard lb) 
    { 
     // get the user ids 
     List<string> userIds = new List<string>(); 

     foreach(IScore score in lb.scores) { 
      userIds.Add(score.userID); 
     } 
     // load the profiles and display (or in this case, log) 
     Social.LoadUsers(userIds.ToArray(), (users) => 
      { 
       string status = "Leaderboard loading: " + lb.title + " count = " + 
        lb.scores.Length; 
       foreach(IScore score in lb.scores) { 
        Debug.Log("" + score.rank + ":" + score.userID); 

       } 
       Debug.Log(status); 
      }); 
    } 

public void DisplayGPScore(){ 

     ILeaderboard lb = PlayGamesPlatform.Instance.CreateLeaderboard(); 
     lb.id = ZRayGameManager.WORLD_LEADERBOARD_ID; 
     lb.LoadScores(ok => 
      { 
       if (ok) { 
        LoadUsersAndDisplay(lb); 
       } 
       else { 
        Debug.Log("Error retrieving leaderboardi"); 
       } 
      }); 
    } 

public void PostScore(int score){ 
     PlayGamesPlatform.Instance.ReportScore(score, ZRayGameManager.WORLD_LEADERBOARD_ID, (bool success) => { 

      if(success){ 
       Debug.Log("High score " + score + " posted"); 
      }else{ 
       Debug.Log("High score " + score + " could not be posted"); 

      } 

     }); 

    } 

를 사용하여 I는 코드 (제외 관계없는 부분) I는 다음과 같은 결과를 얻을

단순화 012,351

6,
I/Unity (15970): 
I/Unity (15970): Authentication successful 
I/Unity (15970): 
I/Unity (15970): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe 
bugBindings.gen.cpp Line: 37) 
I/Unity (15970): 
I/Unity (15970): Username: RighthandedTuba240 
I/Unity (15970): User ID: g02637898988054749692 
I/Unity (15970): IsUnderage: True 
I/Unity (15970): 
I/Unity (15970): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe 
bugBindings.gen.cpp Line: 37) 
I/Unity (15970): 
I/Unity (15970): [Play Games Plugin DLL] 07/17/16 18:46:52 +03:00 DEBUG: Repo 
rtScore: score=100, board=CgkIppHPm-wIEAIQCQ 
I/Unity (15970): 
I/Unity (15970): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe 
bugBindings.gen.cpp Line: 37) 
I/Unity (15970): 
I/Unity (15970): [Play Games Plugin DLL] 07/17/16 18:46:52 +03:00 DEBUG: Nati 
ve Submitting score: 100 for lb CgkIppHPm-wIEAIQCQ with metadata: 
I/Unity (15970): 
I/Unity (15970): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe 
bugBindings.gen.cpp Line: 37) 
I/Unity (15970): 
I/Unity (15970): User is authenticated 
I/Unity (15970): 
I/Unity (15970): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe 
bugBindings.gen.cpp Line: 37) 
I/Unity (15970): 
I/Unity (15970): [Play Games Plugin DLL] 07/17/16 18:46:52 +03:00 DEBUG: Load 
Scores, board=GooglePlayGames.PlayGamesLeaderboard callback is System.Action`1[S 
ystem.Boolean] 
I/Unity (15970): 
I/Unity (15970): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe 
bugBindings.gen.cpp Line: 37) 
I/Unity (15970): 
I/Unity (15970): [Play Games Plugin DLL] 07/17/16 18:46:52 +03:00 DEBUG: Invo 
king user callback on game thread 
I/Unity (15970): 
I/Unity (15970): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe 
bugBindings.gen.cpp Line: 37) 
I/Unity (15970): 
I/Unity (15970): High score 100 posted 
I/Unity (15970): 
I/Unity (15970): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe 
bugBindings.gen.cpp Line: 37) 
I/Unity (15970): 
I/Unity (15970): [Play Games Plugin DLL] 07/17/16 18:46:55 +03:00 DEBUG: Ente 
ring internal callback for LeaderboardManager#InternalFetchCallback 
I/Unity (15970): 
I/Unity (15970): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe 
bugBindings.gen.cpp Line: 37) 
I/Unity (15970): 
I/Unity (15970): [Play Games Plugin DLL] 07/17/16 18:47:10 +03:00 DEBUG: Star 
ting Auth Transition. Op: SIGN_OUT status: ERROR_NOT_AUTHORIZED 
I/Unity (15970): 
I/Unity (15970): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe 
bugBindings.gen.cpp Line: 37) 
I/Unity (15970): 
I/Unity (15970): [Play Games Plugin DLL] 07/17/16 18:47:10 +03:00 DEBUG: Ente 
ring internal callback for LeaderboardManager#InternalFetchSummaryCallback 
I/Unity (15970): 
I/Unity (15970): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe 
bugBindings.gen.cpp Line: 37) 
I/Unity (15970): 
W/Unity (15970): !!! [Play Games Plugin DLL] 07/17/16 18:47:10 +03:00 WARNING: 
Error returned from fetchScoreSummary: GooglePlayGames.Native.PInvoke.FetchScor 
eSummaryResponse 
W/Unity (15970): 
W/Unity (15970): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe 
bugBindings.gen.cpp Line: 37) 
W/Unity (15970): 
I/Unity (15970): [Play Games Plugin DLL] 07/17/16 18:47:10 +03:00 DEBUG: Invo 
king user callback on game thread 
I/Unity (15970): 
I/Unity (15970): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe 
bugBindings.gen.cpp Line: 37) 
I/Unity (15970): 
I/Unity (15970): Error retrieving leaderboardi 

결론 :

  1. 에서 메소드 로그인()가 성공적으로 인증을 알려주고 사용자 정보를 출력하기 때문에 사용자가 인증 할 수 있습니다.

  2. 사용자는 점수 판에 그/그녀의 점수를 게시 할 수 있으며, PostScore 방법을 알려주기 때문에

의 오류,

  • 이 사용자는 점수 판 점수를 표시 할 수 없습니다 "높은 점수 (100)는 게시"

    승/유니티 (15970) : !!! 00 경고 : 오류 fetchScoreSummary에서 반환 : 07/17/16 18시 47분 10초 03는 [게임 플러그인 DLL을 재생] GooglePlayGames.Native.PInvoke.FetchScor eSummaryResponse

    내가 점수 판의 설정을 찾을 수 없습니다

    콘솔에서 사용자가이 스코어 보드에 액세스 할 수있게하십시오.

    도와주세요!여기에 2 주간 붙어 있습니다 (하지만 개선이 있었지만 3 일 전에 로그인 할 수 없었습니다)

  • +0

    안녕하십니까? 아직이 문제가 발생합니까? –

    답변

    0

    리더 보드를 표시하려면 startActivityForResult을 호출하고 기본 리더 보드 UI를 작성해야합니다. . 다음 코드 스 니펫에서 REQUEST_LEADERBOARD은 요청 코드의 임의의 정수입니다.

    Private void loadScoreOfLeaderBoard() { 
    Games.Leaderboards.loadCurrentPlayerLeaderboardScore(getApiClient(), getString(R.string.your_leaderboard_id), LeaderboardVariant.TIME_SPAN_ALL_TIME, LeaderboardVariant.COLLECTION_PUBLIC).setResultCallback(new ResultCallback<Leaderboards.LoadPlayerScoreResult>() { 
    @Override 
    public void onResult(final Leaderboards.LoadPlayerScoreResult scoreResult) { 
    if (isScoreResultValid(scoreResult)) { 
    // here you can get the score like this 
    mPoints = scoreResult.getScore().getRawScore(); 
    } 
    } 
    }); 
    } 
    
    private boolean isScoreResultValid(final Leaderboards.LoadPlayerScoreResult scoreResult) { 
    return scoreResult != null && GamesStatusCodes.STATUS_OK == scoreResult.getStatus().getStatusCode() && scoreResult.getScore() != null; 
    } 
    

    SIGN_OUT status: ERROR_NOT_AUTHORIZED

    는 당신이 바로 SHA1 fingerprint이 있는지 확인하십시오 :

    startActivityForResult(Games.Leaderboards.getLeaderboardIntent(mGoogleApiClient, 
    LEADERBOARD_ID), REQUEST_LEADERBOARD); 
    

    는 플레이어의 점수를 얻을. Google Play services과의 통합으로 Android에서 요청을 인증하는 작업이 다른 인증 워크 플로와 다릅니다.

    모든 애플리케이션은 OAuth 2.0을 사용하여 Google API에 액세스 할 때 기본 패턴을 따릅니다. 높은 수준에서 다음 4 단계를 수행합니다.

    • Google API 콘솔에서 OAuth 2.0 자격증 명을 얻습니다.
    • Google 인증 서버에서 액세스 토큰을 받으십시오.
    • API에 액세스 토큰을 보냅니다.
    • 필요한 경우 액세스 토큰을 새로 고칩니다.
    +0

    안녕하세요, 귀하의 답변에 감사하지만 Unity에서 C#으로 스크립팅되어 Android 용 게임을 만들었습니다. 귀하의 솔루션은 Android - Java Android Studio 종류의 것 같습니다. SHA 지문을 여러 번 확인했습니다 : / – fercis

    관련 문제