简体   繁体   English

如何在 Unity3D 上为 android 显示 Google Play 游戏“欢迎回来”祝酒词?

[英]How to show a Google Play Games “Welcome Back” toast for android on Unity3D?

I'm already using the official plugin, logging in for the first time works perfectly and we can see the "Welcome + username" with a little avatar message popping up.我已经在使用官方插件了,第一次登录完美,我们可以看到“欢迎+用户名”,并弹出一个小头像消息。

However, I do not see the "Welcome back" message that supposedly should appear whenever the user logs in silently (not showing a login prompt).但是,我没有看到应该在用户静默登录时出现的“欢迎回来”消息(不显示登录提示)。 In some games such as Crossy Road you do get the "Welcome" popup if the user silently logs in.在某些游戏(例如 Crossy Road)中,如果用户静默登录,您确实会看到“欢迎”弹出窗口。

A little example of what I am doing using minimal code:我正在使用最少的代码做的一个小例子:

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

public class GooglePlayLogic : MonoBehaviour {

    void Start ()
    {
        PlayGamesPlatform.Activate ();
        SilentSignIn();
    }

    public void SilentSignIn()
    {
        if (!PlayGamesPlatform.Instance.localUser.authenticated)
        {
            PlayGamesPlatform.Instance.Authenticate ((bool success) => {
                if (success) {
                     //some code here
                 } else {
                    //some code here
                 }
            }, true); //true means no login prompt will show up
        } else {
            Debug.Log("Already signed in");
        }
    }
}

However, the normal "Welcome" popup always shows up if the user manually logs out and then logs in again.但是,如果用户手动注销然后再次登录,则始终会显示正常的“欢迎”弹出窗口。 The issue here is that no message is showing up after the silent log in. What do I do for that to appear?这里的问题是在静默登录后没有显示任何消息。我该怎么做才能出现?

Very simple.很简单的。 You have to call Android's native toast method.你必须调用 Android 的原生 toast 方法。

Try this: Toast on Image Detection in Vuforia either using Unity or Java without C++试试这个: 在 Vuforia 中使用 Unity 或 Java 进行图像检测 Toast,不使用 C++

The silent login is usually, well, silent.静默登录通常是静默的。 The underlying authentication flow only shows the welcome toast if it has been some time since it was shown, or as you pointed out, when the sign in process is after explicitly calling sign out.底层身份验证流程仅在自显示以来已经有一段时间显示欢迎祝酒词,或者如您所指出的那样,当登录过程在显式调用注销之后。

Other than being noticeable and a little unsettling during testing, I am curious why want you it shown each time the game activity is resumed (or created)?除了在测试过程中很明显和有点令人不安之外,我很好奇为什么每次恢复(或创建)游戏活动时都要显示它?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM