How connect Unity3D to Steem?

Words
256
Reading
2 min
Listen
Play
8y

Unity3D is a game engine, but we can use it for other purposes, for example to get data from blockchain STEEM. What we can gain by this? Whatever you want :)

What we need?
► Unity3D | Link
Steem.NET by arcange@arcange | Link
→ And check this Link

Now we have to put files from the "classes.CS" folder into the Assets of our project. Probably there will be errors, but don't worry :)

Unity uses the .NET 3.5 version by default, we have to change to version 4.6.
File → Build Settings → Player Settings → Other Settings and change Scripting Runtime Version from .NET 3.5 to .NET 4.6 and restart Unity.

Next step is fix the error with "arrParams". We need Newtonsoft.Json.dll, but for Unity. In Asset Store we have to find a JSON .NET For Unity and import it.

Now, we can check error with the "arrParams" and fix it (missing semicolon). Then, there shouldn't be any error.
In CSteemD and CSteemWallet we have to change string var strHostname on function to "https://api.steemit.com" with port 443 and in CWebSocketstrURI

Now we can create a script in which we will get data. In CSteemD there are probably all functions to interact with steem blockchain. For example I get title and body from my post. Create a new script (my is "GetMyContent") and put this script.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Newtonsoft.Json;

public class GetMyContent : MonoBehaviour {
    
    SteemAPI.CS.CSteemd dSteem;

    void Start () {
        dSteem = new SteemAPI.CS.CSteemd ();
        GetBody ();
    }
    

    void Update () {
        
    }
    public void GetBody(){
        //get full post
        var post = dSteem.get_content ("chewing", "zrobmy-sobie-gre-2-organizacja-obiektow");
        //get what you need
        var title = post ["title"];
        var body = post ["body"];
        Debug.Log ("TITLE: " + title);
        Debug.Log (body);
    }
}



This is result:

What can we do with this? Who interact wallet can make a game with microtransaction. Steem browser as an application. What we want :)

How connect Unity3D to Steem? | Ecency