Sample of Unity app on Expload platform
This is a simple app that using Unity implementaion of Pravda DApp API for Expload Desktop.
- Clone this repo
ProgramTestas Unity Project
- Select Send Button in Canvas
GUI.csas Script for this button
Structure of the repository
Assets contains C# sources including:
ExploadUnityCodegen.csis auxiliary file for generated
Program.csthat forms requests and parses responses of DApp API.
Program.csis generated file that exposes functionality to call program's methods and parse the raw results.
GUI.csoperates with Unity graphics and UI and uses functionality from
SmartProgram.cs is C# source file that is compiled to
SmartProgram.exe and translated to Pravda program
SmartProgram.pravda by the following commands:
csc SmartProgram.cs -reference:Pravda.dll pravda compile dotnet -i SmartProgram.exe -o SmartProgram.pravda
You can find
ExploadUnityCodegen.cs were generated from
pravda gen unity -i SmartProgram.pravda
This command will create
Assets folder and place all generated files to it.
SmartProgram.cs contains three methods:
Emitthat emits tokens to the sender's balance;
BalanceOfthat checks balance of the given address;
Tansferthat can transfer coins to other address.
pravda gen unity analyses these methods and generate appropriate classes (
For detailed description of how these classes were genereated you can look here.
This Unity app has very simple GUI where you should specify address of program in the blockchain, what method to run and arguments for chosen method.
It contains only
SampleScene that is shown at the following picture: