简体   繁体   English

如何在Unity中添加Google Play游戏注册脚本

[英]How to add Google Play Games sign up script in Unity

I want to know how to implement google Play games services to any Unity app. 我想知道如何将Google Play游戏服务实施到任何Unity应用。 I was just going through some tutorials but it's not working, I don't know where I am doing it wrong... maybe there's some mistake I am making in my script but I couldn't find it. 我只是在看一些教程,但没有用,我不知道我在哪里做错了……也许我在脚本中犯了一些错误,但我找不到。 Can anyone tell me what should I do to make it work? 谁能告诉我应该怎么做才能使其正常工作?

I have an empty game object in my scene and I have attached the script to it. 我的场景中有一个空的游戏对象,并且已将脚本附加到该对象。 I just want the sign in using Google prompt window to be launched when I launch the app and if user has already logged in it should not prompt the log in window. 我只希望在启动应用程序时启动使用Google提示登录窗口,并且如果用户已经登录,则不应提示登录窗口。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using UnityEngine.SocialPlatforms;

public class PlayGameServices : MonoBehaviour {
public void Start () {

    //Google Play Services
    PlayGamesPlatform.Activate();

    PlayGamesPlatform.DebugLogEnabled = true;

    pSLogin ();

}

public void Update () {

}

//Google Play Services for login
public void pSLogin()
{
    Social.localUser.Authenticate((bool success) =>
        {
            if(success)
            {
                Debug.Log("You've successfully logged in");                 
            }
            else
            {
                Debug.Log("Log in Unsuccessful");
            }
    });
}
}

The Google Play Games plugin for Unity® is an open-source project whose goal is to provide a plugin that allows game developers to integrate with the Google Play Games API from a game written in Unity®. 适用于Unity®的Google Play游戏插件是一个开源项目,其目标是提供一个插件,使游戏开发人员可以与使用Unity®编写的游戏中的Google Play Games API集成。 However, this project is not in any way endorsed or supervised by Unity Technologies. 但是,Unity Technologies不以任何方式认可或监督该项目。 Use instruction from here 这里使用说明

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

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