Crypt0gnome avatar

Introducing Hive Keychain for Unity!

crypt0gnome

Published: 06 Dec 2022 › Updated: 06 Dec 2022Introducing Hive Keychain for Unity!

Introducing Hive Keychain for Unity!

image.png

I wanted to create an example project to help the community learn how to connect keychainHive account@keychain to a Unity project, this should be helpful for game and application developers looking for a easy to setup option.

This is currently an Unity Scene in the simplest form showing you how to Connect and using your username and set it to PlayerPrefs in the Unity Project. There are also some other simple examples but you will have to adjust the code to fit your needs until I build more on this. I Plan to make a simple dapp/ game in the future that I will open source showing how it can be used in more detail but think this is needed in the space to bring more indie developers to the Hive blockchain and will continue to build it out over the next few months.

Here is a snippet of the connect function, pretty simple.

    public void ConnectWallet()
    {
        #if !UNITY_EDITOR && UNITY_WEBGL
        GameObject canvas = GameObject.Find("Canvas");
        //get text input from usernameInput TextMesh InputField
        TMP_InputField usernameInput = canvas.transform.Find("usernameInput").GetComponent<TMP_InputField>();
        
        if (usernameInput.text == "")
        {
            //create webgl alert
            Application.ExternalEval("alert('Username is empty, please enter your hive username & use hive keychain to sign in')");
        }
        else
        {
            //if not empty, connect to hive keychain
            Debug.Log("Username Sent: " + usernameInput.text);
            Connect(usernameInput.text);
        }
        #endif
    }

and a simple transfer

    public void Transfer()
    {
        #if !UNITY_EDITOR && UNITY_WEBGL
  
        Transfer(username, "crypt0gnome", "1", "test xfer unity");
        #endif
    }

You can view the full repo here and perhaps this should be bookmarked somewhere for users looking to find this in the future.

https://github.com/CryptoGnome/Hive-KeyChain-Unity

If you want to help support me you can check out my other project on Hive splitnterboostHive account@splitnterboost or vote for us as wintess here

Leave Introducing Hive Keychain for Unity! to:

Written by

Building @Terracore & @hive-swap.com on #HIVE

Read more #hivedevs posts


Best Posts From Crypt0gnome

We have not curated any of crypt0gnome's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From Crypt0gnome