Signal-K / Unity-Demo

Showing off the cool stuff in the game Star Sailors
MIT License
2 stars 0 forks source link

Chainsafe SDK Injection #28

Open Gizmotronn opened 2 years ago

Gizmotronn commented 2 years ago

WebLogin.cs script:

using System;
using System.Runtime.InteropServices;
using UnityEngine;
using UnityEngine.SceneManagement;

#if UNITY_WEBGL
public class WebLogin : MonoBehaviour
{
    [DllImport("__Internal")]
    private static extern void Web3Connect();

    [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()
    {
        Web3Connect();
        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()
    {
        // burner account for skipped sign in screen
        PlayerPrefs.SetString("Account", "");
        // move to next scene
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
    }
}
#endif
Gizmotronn commented 2 years ago

Remix

Metadata of "subtracttoken" was published successfully.
contracts/Counter.sol : 
dweb:/ipfs/QmQ1oWFqad62DDvpeMi9SQ79CJuSmgeYCQpciP4cLb5ePJ
metadata.json : 
dweb:/ipfs/QmWEoth4v9gNaFMotBmyafcHKu9o2RTbeEmpTVEXZwz8v5

Commit for this: https://github.com/Signal-K/Unity-Demo/commit/ba888bd779d81ef5a31592e3e2c760defecc5c43