【发布时间】:2021-12-02 11:29:21
【问题描述】:
大家。 我已经制作了我的普通 3D 游戏,需要与 NFT 集成。 所以我需要做的第一件事是在独立/移动平台中连接元掩码。 我尝试使用 web3 但仅适用于 WebGL。 如果有人能解决这个问题,将不胜感激。 谢谢。
【问题讨论】:
-
请提供足够的代码,以便其他人更好地理解或重现问题。
标签: c# unity3d blockchain web3
大家。 我已经制作了我的普通 3D 游戏,需要与 NFT 集成。 所以我需要做的第一件事是在独立/移动平台中连接元掩码。 我尝试使用 web3 但仅适用于 WebGL。 如果有人能解决这个问题,将不胜感激。 谢谢。
【问题讨论】:
标签: c# unity3d blockchain web3
我被这个问题困扰了一周。 我在我的项目中导入了 Web3 unity 包,并使用 [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)
【讨论】: