试图弄清楚这个GPG插件出了什么问题。我按照说明操作并了解文档,以便通过此one测试运行登录和显示排行榜UI。我确实通过Google Play开发者帐户制作了游戏成就+排行榜,进行了设置,复制粘贴来源和完成。通过添加 Admob Unity软件包和GPG Unity软件包测试广告,效果非常好。我甚至更新了Android的一些插件(等.aar文件,firebase-common,manifest),以便最大限度地提高兼容性和效率,这样我就可以构建APK而不会出现任何干扰构建的问题。
然而,有一个问题:在我登录并尝试点击"显示排行榜UI"按钮以及询问用户是否经过身份验证的按钮事件,它将允许您在显示排行榜UI之前通过更新来记录最新的高分。以下是代码的工作原理:
首先,在Start()回调...
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
.Build();
PlayGamesPlatform.InitializeInstance(config);
PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.Activate();
接下来,这是登录/注销过程......
public void LogInAccount() {
// Show dialog.
y = 0;
dialogPanel.SetActive (true);
dialogBackground.SetActive (true);
// You can logout if you're logged in.
if(Social.localUser.authenticated) {
((PlayGamesPlatform)Social.Active).SignOut ();
y = 0;
message.text = "Your account have been logged out.";
logButtonLabel.text = "Log-in via Google";
button.SetActive (true);
confirmSound.Play();
return;
}
// Check for status.
if (CheckNetwork.checkOnlineStatus ()) {
Social.localUser.Authenticate ((bool success) => {
if (success) {
// LOG IN SUCCESS! (Check if the email is identified or not.)
if((((PlayGamesLocalUser)Social.localUser).Email != null) || (((PlayGamesLocalUser)Social.localUser).Email != "")) {
y = 0;
message.text = "Login complete. However, email is not verified or unknown.";
logButtonLabel.text = "Log-out";
button.SetActive (true);
errorSound.Play();
} else {
y = 0;
message.text = "Login complete!\nYour email:" + ((PlayGamesLocalUser)Social.localUser).Email;
logButtonLabel.text = "Log-out";
button.SetActive (true);
confirmSound.Play();
}
} else if (!success) {
// LOG IN FAILED.
if((((PlayGamesLocalUser)Social.localUser).Email != null) || (((PlayGamesLocalUser)Social.localUser).Email != "")) {
message.text = "Login failed. Please try again later.\nYour email: ? ? ?";
} else {
message.text = "Login failed. Please try again later.\nYour email: " + ((PlayGamesLocalUser)Social.localUser).Email;
}
y = 0;
button.SetActive (true);
logButtonLabel.text = "Log-in via Google";
errorSound.Play();
}
});
} else {
message.text = "Connection is lost. Please enable online.";
button.SetActive (true);
}
}
然后,显示排行榜回调/按钮事件。
public void OpenLeaderboard() {
// Show dialog.
y = 0;
dialogPanel.SetActive (true);
dialogBackground.SetActive (true);
// Check for status.
if (Social.localUser.authenticated && CheckNetwork.checkOnlineStatus ()) {
// Updating your highscore...
Social.ReportScore ((long)Score.GetScore (),
AchievementReference.leaderboard_best_intergalactic_chasers_top_score,
(bool success) => {
if(success) {
// LEADERBOARD APPEARED!
dialogPanel.SetActive (false);
dialogBackground.SetActive (false);
confirmSound.Play();
Social.ShowLeaderboardUI();
// ((PlayGamesPlatform)Social.Active).ShowLeaderboardUI(AchievementReference.leaderboard_best_intergalactic_chasers_top_score);
} else {
y = 0;
message.text = "Load failed. Please try again later.";
button.SetActive (true);
errorSound.Play();
}
});
} else if (!Social.localUser.authenticated) {
y = 0;
confirmSound.Play();
button.SetActive (true);
if (!CheckNetwork.checkOnlineStatus ()) {
message.text = "Connection not available at a moment.";
} else if (CheckNetwork.checkOnlineStatus ()) {
message.text = "You must login first in order to see the leaderboard.";
}
}
}
在我第一次尝试时,我会登录(有时会显示欢迎标志)并点击排行榜按钮但2分钟后没有任何反应。第二次尝试,我做login-logout-login方法,GPG提示我选择电子邮件地址,欢迎用户名签名出现在顶部。但是,当我点击节目排行榜UI按钮时,3分钟后没有任何反应。我使用this引用来获得有关显示leaderboardc UI并检查代码示例的更多想法。最后的尝试,我认为排行榜UI不会出现,直到我发布我创建的游戏服务(之前已经设置为测试模式)并查看排行榜UI是否正常工作。然后在一两天后,从第一次尝试使用相同的方法,但仍然没有运气。
问题是:在测试模式期间甚至在通过Google Play服务开发人员部分发布游戏服务后,排行榜用户界面如何仍然无法显示?在Achievements UI中显示同样的事情。即使我在设置上正确地执行了操作,阻止排行榜UI显示的原因是什么?我怀疑是因特网连接问题还是wifi信号。问题可能是我所做的非常简单的游戏服务的长期负担。我只创造了两个排行榜(高分和没有被毁的船只)和五个成就达到一定的分数而没有。船只被毁坏了。
此外,除了显示排行榜用户界面问题之外,还有一个错误,即使通过Google帐户成功登录后,字符串值(实际上是我选择的电子邮件地址检索)为null或为空通过屏幕顶部的欢迎用户名标记。
更新 我检查了错误并提供了来自 S的解决方案。 Tarik Cetin ,我在logcat上查了一下登录信息。起初,我认为它成功登录。然后,我注意到了这一点:
W/Unity (32099): *** [Play Games Plugin DLL] 07/05/16 14:33:54 -07:00 ERROR: E
xception launching token request: java.lang.ClassNotFoundException: com.google.g
ames.bridge.TokenFragment
W/Unity (32099):
W/Unity (32099): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe
bugBindings.gen.cpp Line: 37)
W/Unity (32099):
W/Unity (32099): *** [Play Games Plugin DLL] 07/05/16 14:33:54 -07:00 ERROR: U
nityEngine.AndroidJavaException: java.lang.ClassNotFoundException: com.google.ga
mes.bridge.TokenFragment
W/Unity (32099): java.lang.ClassNotFoundException: com.google.games.bridge.Tok
enFragment
W/Unity (32099): at java.lang.Class.classForName(Native Method)
W/Unity (32099): at java.lang.Class.forName(Class.java:217)
W/Unity (32099): at java.lang.Class.forName(Class.java:172)
W/Unity (32099): at com.unity3d.player.UnityPlayer.nativeRender(Native Me
thod)
W/Unity (32099): at com.unity3d.player.UnityPlayer.a(Unknown Source)
W/Unity (32099): at com.unity3d.player.UnityPlayer$b.run(Unknown Source)
W/Unity (32099): Caused by: java.lang.NoClassDefFoundError: com/google/games/b
ridge/TokenFragment
W/Unity (32099): ... 6 more
W/Unity (32099): Caused by: java.lang.ClassNotFoundException: com.google.games
.bridge.TokenFragment
W/Unity (32099): at dalvik.system.BaseDexClassLoader.findClass(BaseDexCla
ssLoader.java:61)
W/Unity (32099): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
W/Unity (32099): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
W/Unity (32099): ... 6 more
W/Unity (32099): at UnityEngine.AndroidJNISafe.CheckException () [0x00000] i
n <filename unknown>:0
W/Unity (32099): at UnityEn
另外,当我登录和退出一次时,我遇到了我的logcat状态。
W/Unity (32099): at UnityEn
I/Unity (32099): [Play Games Plugin DLL] 07/05/16 14:38:07 -07:00 DEBUG: Star
ting Auth Transition. Op: SIGN_OUT status: ERROR_NOT_AUTHORIZED
I/Unity (32099):
I/Unity (32099): (Filename: ./artifacts/generated/common/runtime/UnityEngineDe
bugBindings.gen.cpp Line: 37)
I/Unity (32099):
最后,这是在尝试直接打开排行榜UI时发现的问题。
W/Unity (32099): *** [Play Games Plugin DLL] 07/05/16 14:40:31 -07:00 ERROR: U
nityEngine.AndroidJavaException: java.lang.ClassNotFoundException: com.google.ga
mes.bridge.NativeBridgeActivity
W/Unity (32099): java.lang.ClassNotFoundException: com.google.games.bridge.Nat
iveBridgeActivity
W/Unity (32099): at java.lang.Class.classForName(Native Method)
W/Unity (32099): at java.lang.Class.forName(Class.java:217)
W/Unity (32099): at java.lang.Class.forName(Class.java:172)
W/Unity (32099): at com.unity3d.player.UnityPlayer.nativeRender(Native Me
thod)
W/Unity (32099): at com.unity3d.player.UnityPlayer.a(Unknown Source)
W/Unity (32099): at com.unity3d.player.UnityPlayer$b.run(Unknown Source)
W/Unity (32099): Caused by: java.lang.NoClassDefFoundError: com/google/games/b
ridge/NativeBridgeActivity
W/Unity (32099): ... 6 more
W/Unity (32099): Caused by: java.lang.ClassNotFoundException: com.google.games
.bridge.NativeBridgeActivity
W/Unity (32099): at dalvik.system.BaseDexClassLoader.findClass(BaseDexCla
ssLoader.java:61)
W/Unity (32099): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
W/Unity (32099): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
W/Unity (32099): ... 6 more
W/Unity (32099): at UnityEngine.AndroidJNISafe.CheckException () [0x00000] i
n <filen
更新 我在检查电子邮件是否为空时犯了一个错误。我读错了。虽然,电子邮件地址值仍然存在问题,它应该以字符串值的形式返回,并在读取非空时留空。
// LOG IN SUCCESS! (Check if the email is identified or not.)
if((((PlayGamesLocalUser)Social.localUser).Email != null) || (((PlayGamesLocalUser)Social.localUser).Email != "")) {
y = 0;
message.text = "Login complete!\nYour email:" + ((PlayGamesLocalUser)Social.localUser).Email;
logButtonLabel.text = "Log-out";
button.SetActive (true);
confirmSound.Play();
} else {
y = 0;
message.text = "Login complete. However, email is not verified or unknown.";
logButtonLabel.text = "Log-out";
button.SetActive (true);
errorSound.Play();
}
答案 0 :(得分:-1)
我从App Guruz检查并观察了本教程,并将示例设为一个。我观察了这个游戏如何流动并使用我的包名来修改它。幸运的是,排行榜UI最终出现了。当我尝试从示例项目表格App Guruz网站进行比较时,我认为Android上的插件(某些库文件夹,如 firebase 和.aar文件)存在某些特定问题或问题。可能是兼容性问题。
如果您想制作排行榜的用户界面和内容并依赖this Unity Plugin via GIT website,请远离此软件。它不值得使用它。充满了bug,特别是Android插件。首先从头开始制作自己的GPG并观察插件和罐子,因为我只专注于Android。