Unity移动平台如何连接metamask钱包?

How to connect metamask wallet in Mobile Platform of Unity?

各位。 我已经制作了我的普通 3D 游戏,需要与 NFT 集成。 所以我需要做的第一件事是在 Standalone/Mobile 平台中连接元掩码。 我尝试使用 web3,但只适用于 WebGL。 如果有人能解决这个问题,我们将不胜感激。 谢谢。

我被这个问题困扰了一个星期。 我在我的项目中导入了 Web3 统一包,并使用 [DllImport("__internal")] 在 web3.jslib 插件中连接它的功能。

using System;
using System.Runtime.InteropServices;
using UnityEngine;
using UnityEngine.SceneManagement; 
public class MobileLogin : MonoBehaviour
{
    [DllImport("__Internal")]
    private static extern void MobileConnect();

    [DllImport("__Internal")]
    private static extern string ConnectAccount();

    [DllImport("__Internal")]
    private static extern void SetConnectAccount(string value);

private int expirationTime;
private string account; 

public void OnLogin()
{
    MobileConnect();
    OnConnected();
}

async private void OnConnected()
{
    account = ConnectAccount();
    while (account == "") {
        await new WaitForSeconds(1f);
        account = ConnectAccount();
    };
    // save account for next scene
    PlayerPrefs.SetString("Account", account);
    // reset login message
    SetConnectAccount("");
    // load next scene
    SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}

public void OnSkip(){
    // move to next scene
    SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);    
}}

但是当它运行时,我遇到了这个错误:

EntryPointNotFoundException: MobileConnect
WebLogin.OnLogin () (at Assets/Web3Unity/Scripts/Scenes/WebLogin.cs:23)
UnityEngine.Events.InvokableCall.Invoke () (at 
<7d87237cea3743d093e22c5b98f74fba>:0)
UnityEngine.Events.UnityEvent.Invoke () (at 
<7d87237cea3743d093e22c5b98f74fba>:0)