Introducing Hive Keychain for Unity!

in #hivedevslast year (edited)

image.png

I wanted to create an example project to help the community learn how to connect @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 @splitnterboost or vote for us as wintess here

Sort:  

🍕 PIZZA !
@crypt0gnome! The Hive.Pizza team manually upvoted your post.

I gifted $PIZZA slices here:
@iviaxpow3r(1/5) tipped @crypt0gnome (x1)

Learn more at https://hive.pizza!

Congratulations @crypt0gnome! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)

You received more than 500 upvotes.
Your next target is to reach 600 upvotes.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Check out the last post from @hivebuzz:

HiveBuzz World Cup Contest - Round of 16 - Recap of Day 3
The Hive Gamification Proposal Renewal
Our Hive Power Delegations to the November PUM Winners
Support the HiveBuzz project. Vote for our proposal!

This is awesome @crypt0gnome !!

!PIZZA !LUV !ALIVE

@crypt0gnome! You Are Alive so I just staked 0.1 $ALIVE to your account on behalf of @iviaxpow3r. (1/10)

The tip has been paid for by the We Are Alive Tribe through the earnings on @alive.chat, feel free to swing by our daily chat any time you want.


~~~ embed:1600592611450171393 twitter metadata:NDA3MTk3NDh8fGh0dHBzOi8vdHdpdHRlci5jb20vNDA3MTk3NDgvc3RhdHVzLzE2MDA1OTI2MTE0NTAxNzEzOTN8 ~~~
The rewards earned on this comment will go directly to the people( @iviaxpow3r, @ubikalo ) sharing the post on Twitter as long as they are registered with @poshtoken. Sign up at https://hiveposh.com.

Dear @crypt0gnome,
May I ask you to review and support the new HiveSQL Proposal so we can keep it free to use for the community?
You can do it on Peakd, ecency,

Hive.blog / https://wallet.hive.blog/proposals
or using HiveSigner

Thank you!

Very interesting post, I am working with some AR basics in Unity, and you are joining Hive with Unity, I wonder what future will bring us, good job bro

Keep me posted on what you are working on!

sure! I will.

Very interesting!
!discovery 30


This post was shared and voted inside the discord by the curators team of discovery-it
Join our community! hive-193212
Discovery-it is also a Witness, vote for us here
Delegate to us for passive income. Check our 80% fee-back Program

Hey man what verison of Unity is this built for??
I tried cloning it today and had errors.