代码之家  ›  专栏  ›  技术社区  ›  Alex Boullé

Unity-谷歌游戏服务不工作?

  •  1
  • Alex Boullé  · 技术社区  · 8 年前

    好吧,所以我以前已经成功地在很多游戏中实现了GPGS,但现在似乎行不通了。我加载了游戏,它不会做任何事情,没有登录对话框或任何事情。这是我用来登录的代码:

    using UnityEngine;
    using System.Collections;
    using UnityEngine.SocialPlatforms;
    using GooglePlayGames;
    using GooglePlayGames.BasicApi;
    
    public class GpgsStart : MonoBehaviour {
    
    
    void Start () {
            PlayGamesPlatform.Activate ();
            Social.localUser.Authenticate((bool success) => {
                if(!success)
                {
                    PlayerPrefs.SetString("SignIn", "false");
                    Debug.Log("Couldn't Sign In");
                }
            });
        }
    
        // Update is called once per frame
        void Update () {
    
        }
    }
    

    我真的不明白为什么它不起作用,我想知道是我犯了一个愚蠢的错误还是我错过了什么。有人知道是什么导致了我的问题吗?

    非常感谢您的帮助,谢谢。

    这是logcat输出:

    I/Unity   ( 9861): InvalidOperationException: There was an error creating a Game
    Services object. Check for log errors from GamesNativeSDK
    I/Unity   ( 9861):   at GooglePlayGames.Native.PInvoke.GameServicesBuilder.Build
     (GooglePlayGames.Native.PInvoke.PlatformConfiguration configRef) [0x00000] in <
    filename unknown>:0
    I/Unity   ( 9861):   at GooglePlayGames.Native.NativeClient.InitializeGameServic
    es () [0x00000] in <filename unknown>:0
    I/Unity   ( 9861):   at GooglePlayGames.Native.NativeClient.Authenticate (System
    .Action`1 callback, Boolean silent) [0x00000] in <filename unknown>:0
    I/Unity   ( 9861):   at GooglePlayGames.PlayGamesPlatform.Authenticate (System.A
    ction`1 callback, Boolean silent) [0x00000] in <filename unknown>:0
    I/Unity   ( 9861):   at GooglePlayGames.PlayGamesPlatform.Authenticate (System.A
    ction`1 callback) [0x00000] in <filename unknown>:0
    I/Unity   ( 9861):   at GooglePlayGames.PlayGamesLocalUser.Authenticate (System.
    Action`1 callback) [0x00000] in <filename unknown>:0
    I/Unity   ( 9861):   at GpgsStart.Start () [0x00000] in <filename unknown>:0
    I/Unity   ( 9861):
    I/Unity   ( 9861): (Filename:  Line: -1)
    I/Unity   ( 9861):
    V/WindowManager(  451): Window{422852e8 u0 Keyguard}mOrientationRequetedFromKeyg
    uard=false
    
    2 回复  |  直到 8 年前
        1
  •  3
  •   Clayton Wilkinson    8 年前

    这很可能是由旧版本的googleplay服务客户端库引起的。如果缺少java类,Games SDK将无法正确初始化。您可以通过在日志中查找之前未找到的类错误来确认这一点。

    要解决此问题,请使用SDK管理器将play services SDK更新到最新版本。在Unity中,这是窗口>Google Play游戏>下载>Google Play Games SDK(Android)。。。

    然后再次运行“玩游戏设置”,窗口>Google Play游戏>设置>Android安装…这将把更新客户端库复制到您的Unity项目中。

        2
  •  0
  •   Danish XII    7 年前

    这通常是由于项目中缺少.aar文件。 对于游戏服务,需要一些.aar文件。 将此.aar文件与您的文件进行交叉检查

    1. 播放服务-身份验证-9.2.1
    2. play-services-auth-base-9.2.1
    3. 游戏服务-9.2.1
    4. 游戏服务-地下室-9.2.1
    5. 游戏服务驱动-9.2.1
    6. 游戏服务游戏-9.2.1
    7. 游戏服务-接近9.2.1
    8. 游戏服务任务-9.2.1
    9. 支架-v4-23.4.0

    aar文件的版本可能有所不同,但这对我来说很有用