43 lines
994 B
C#
43 lines
994 B
C#
using Reown.AppKit.Unity;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
|
|
|
|
public class WalletConnectController : MonoBehaviour
|
|
{
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
public async void Start()
|
|
{
|
|
var config = new AppKitConfig();
|
|
await AppKit.InitializeAsync(config);
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
public async Task ResumeSession()
|
|
{
|
|
// Try to resume account connection from the last session
|
|
var resumed = await AppKit.ConnectorController.TryResumeSessionAsync();
|
|
|
|
if (resumed)
|
|
{
|
|
// Continue to the game
|
|
ShowWalletConnected();
|
|
}
|
|
else
|
|
{
|
|
// Connect account
|
|
AppKit.AccountConnected += (_, e) => ShowWalletConnected();
|
|
AppKit.OpenModal();
|
|
}
|
|
}
|
|
public void ShowWalletConnected()
|
|
{
|
|
Debug.Log("Connected");
|
|
}
|
|
}
|
|
|