簡體   English   中英

CS1503:參數 1:無法從“方法組”轉換為“Action,bool>”

[英]CS1503: Argument 1: cannot convert from 'method group' to 'Action,bool>'

我正在嘗試編寫一個腳本並為基於統一 android 的 SSO 獲取 Google 登錄,以讓用戶在我的游戲上創建帳戶。 我從谷歌的開發人員網站獲得的代碼片段之一出現錯誤“CS1503:參數 1:無法從 '方法組' 轉換為 'Action,bool>'”。 https://github.com/playgameservices/play-games-plugin-for-unity/blob/master/README.md?fbclid=IwAR2bIbeEOcwm193e8aL3I9GwqdWoczYR1oNY7jfvCDFnt4Vepu0QfSULctM#sign-in

Social.localUser.Authenticate(ProcessAuthentication); 這一行有這個錯誤被拋出。

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

public class GoogleManager : MonoBehaviour
{
    private bool ;
    public void Start()
    {
       PlayGamesPlatform.Activate();
       Social.localUser.Authenticate(ProcessAuthentication);
    }

internal void ProcessAuthentication(SignInStatus status)
{
    if (status == SignInStatus.Success)
    {
        // Continue with Play Games Services
    }
    else
    {
        // Disable your integration with Play Games Services or show a login button
        // to ask users to sign-in. Clicking it should call
        PlayGamesPlatform.Instance.ManuallyAuthenticate(ProcessAuthentication);
    }
}

}

這里的任何幫助都會很棒。

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

public class GoogleManager : MonoBehaviour
{
public Text m_Message;
public Button m_SignIn;
private UnityAction SignInGooglePlayGames;
private Action<bool> OnGoogleLogin;
private bool success;

private void Awake()
{
    InitializePlayGamesLogin();
}
private void Start()
{
    PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
    .AddOauthScope("profile")
    .RequestServerAuthCode(false)
    .Build();
    PlayGamesPlatform.InitializeInstance(config);

    // recommended for debugging:
    PlayGamesPlatform.DebugLogEnabled = true;

    // Activate the Google Play Games platform
    PlayGamesPlatform.Activate();
    m_SignIn.onClick.RemoveAllListeners();
    m_SignIn.onClick.AddListener(SignInGooglePlayGames);
}
void InitializePlayGamesLogin()
{
    var config = new PlayGamesClientConfiguration.Builder()
        // Requests an ID token be generated.  
        // This OAuth token can be used to
        // identify the player to other services such as Firebase.
        .RequestIdToken()
        .Build();

    PlayGamesPlatform.InitializeInstance(config);
    PlayGamesPlatform.DebugLogEnabled = true;
    PlayGamesPlatform.Activate();
}

public void LoginGoogle()
{
    
    
    Social.localUser.Authenticate(OnGoogleLogin);
    if (success)
    {
        // Call Unity Authentication SDK to sign in or link with Google.
        Debug.Log("Login with Google done. IdToken: " + ((PlayGamesLocalUser)Social.localUser).GetIdToken());
    }
    else
    {
        Debug.Log("Unsuccessful login");
    }
}

}

或者有沒有人設置谷歌播放登錄可以幫助我

謝謝

看起來您使用的是 GPGS 版本 10.14。 在 10.14 版本中,在編寫上述代碼時出現了同樣的錯誤。

以下是解決此問題的方法。


ProcessAuthentication(SignInStatus status)方法更改為以下內容:

internal void ProcessAuthentication(bool status)
{
  if (status)
  {
    // Continue with Play Games Services
  }

  //...
}

或者,您也可以使用以下方法:

internal void ProcessAuthentication(SignInInteractivity status)
{
  if (status == SignInInteractivity.CanPromptOnce)
  {
    // Continue with Play Games Services
  }

  //...
}

10.14v 不支持SignInStatus 可從11.01v 開始

有關詳細信息,請參閱此處的 README.md 文件。


希望你的問題得到解決:)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM