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 | 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 CWebSocket → strURI
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 :)
Hi! Very easy explauned post. I'm learning Unity and in particular I want to crrate PS4 games. Have you tried to build to this plattform?
Thanks
Thanks for creating this! I've implemented it into a game and got it working. I'd like to create a multiplayer game where players bet an amount of Steem, then the winner takes all. Can you point me toward the functions I'd be using in your sdk?
Which game? Do you have a link to your github? I'd like to implement this in unity for Hashkings.