• Stars
    star
    121
  • Rank 293,924 (Top 6 %)
  • Language
    C#
  • License
    Other
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Loom DAppChain SDK for Unity3d

Loom Network SDK for Unity

This repo contains the SDK code and a Unity 2017.4 project that provides examples.

The SDK currently supports the following Unity targets:

  • Desktop Win/macOS/Linux
  • Android
  • iOS
  • WebGL

Requirements

  • Unity 2017.4 or later.
  • Build Settings -> Player Settings -> Configuration set as follows:
    • Scripting Runtime Version: Experimental (.NET 4.6 Equivalent)
    • API Compatibility Level: .NET 4.6

Overview

LoomChainClient provides the means to communicate with a Loom DAppChain from a Unity game, while the Contract class provides a more convenient abstraction that streamlines invoking methods on a specific smart contract running on a DAppChain.

If you haven't done so already now would be a good time to read through the Unity SDK Quickstart.

Adding new transaction types

Create a new .proto file in the Assets\Protobuf directory, refer to Google Protocol Buffers for syntax details etc. You'll need to download the protoc compiler to generate C# classes from the .proto files.

The relevant command will look something like this:

protoc \
  -I<install path>/protoc-3.5.1/include \
  -I<project path>/Assets/Protobuf \
  --csharp_out=<project path>/Assets/Protobuf \
  <project path>/Assets/Protobuf/sample.proto

Samples

The sample authSample scene expects a local Loom DAppChain node to be running on localhost, if you decide to change the default host/ports the node runs on you'll need to update the host/ports in authSample.cs to match.

When you run the sample scene you will see three buttons that are hooked up to call the corresponding methods in Assets/authSample.cs, these must be pressed in the correct order:

  1. Press the Sign In button to generate a new random identity, once you've signed up/in you should see the text above the button change to Signed in as ....
  2. Once the textbox indicates you're signed in you can press the Call SetMsg button to call the SetMsg method in the BluePrint smart contract, this method will store a key/value in the smart contract state. If the method executes without error the textbox should change to Smart contract method finished executing.. You can press the Call SetMsg button again to make another call. Each call to the smart contract actually requires a new transaction to be generated, signed, and then validated by the DAppChain.
  3. Press the Call SetMsgEcho button to call the SetMsgEcho method in the BluePrint smart contract, similarly to SetMsg this method will store a key/value in the smart contract, and return the key/value it stored.
  4. You can press the Call GetMsg button to send a simple query to the BluePrint contract.

Building the SDK

BuildScripts folder contains scripts for building loom-unity-sdk.unitypackage for Windows and macOS. Scripts use the UNITY_PATH environment variable to determine the Unity executable path, if it is set; alternatively, the path can be passed as an argument. As a fallback, standard Unity installation directory might be used. The package is built to Assets\~NonVersioned\loom-unity-sdk.unitypackage.

Dependencies

Here are some notes on the dependencies used and how to update them.

Chaos.NaCl

Download the latest Chaos.NaCl package from NuGet, open as a ZIP archive, use the lib\net40\Chaos.NaCl.dll assembly.

Google Protocol Buffers

Download the latest Google.Protobuf package from NuGet, open as a ZIP archive, use the lib\net45\Google.Protobuf.dll assembly.

Websocket-Sharp

Clone https://github.com/sta/websocket-sharp, build the Release configuration, the output assembly is bin\Release\websocket-sharp.dll.

Nethereum

Download the latest net461dllsAOT.zip release artifact from https://github.com/Nethereum/Nethereum/releases. Only those assemblies are used by the SDK:

Nethereum.ABI.dll
Nethereum.Contracts.dll
Nethereum.Hex.dll
Nethereum.JsonRpc.Client.dll
Nethereum.Model.dll
Nethereum.RLP.dll
Nethereum.RPC.dll
Nethereum.Util.dll
BouncyCastle.Crypto.dll
Common.Logging.Core.dll
Newtonsoft.Json.dll

Dependecy Namespace Prefixing

The SDK contains quite a bit of dependencies, so there is a high chance that a Unity project will contain another version of a dependency for other purposes. Since Unity doesn't have any dependency management for third-party SDKs yet, all dependencies have Loom. prefix added to their namespaces. To do this, AssemblyNamespaceChanger tool is used. The relevant version is already present n the repo.

  1. Acquire/build all dependency assemblies.
  2. Copy them into the BuildScripts\PrefixDependencies\Original folder.
  3. Run the BuildScripts\PrefixDependencies\prefix-dependencies.cmd script. It will prefix the assemblies and put them into the BuildScripts\PrefixDependencies\Processed folder.
  4. Copy the prefixed assemblies from BuildScripts\PrefixDependencies\Processed to UnityProject\Assets\LoomSDK\Plugins.

More Repositories

1

plasma-cash

Plasma Cash Contract & Client. ERC721, ERC20, and ETH compatible
JavaScript
271
star
2

zombie-char-component

Zombie character preview
Vue
242
star
3

loom-js

JS library for building browser apps & NodeJS services that interact with Loom DAppChains
TypeScript
207
star
4

go-loom

Go package for building plugins and Go Smart Contracts for Loom DAppChains
Go
190
star
5

erc721x

ERC721x is an extension of ERC721 that adds support for multi-fungible tokens and batch transfers, while being fully backward-compatible.
Solidity
169
star
6

loomchain

Loom DAppChain Engine
Go
166
star
7

solidityx-js

SolidtyX is an opinionated version of Solidity.
JavaScript
124
star
8

truffle-dappchain-example

Example of Truffle configured with Loom Truffle Provider
JavaScript
92
star
9

solidity-social-example

Super simple social network interaction, where users can post and comment on posts
JavaScript
67
star
10

plasma-paper

Plasma Cash: Towards Improved Plasma Constructions.
TeX
50
star
11

EthDeploy

Ethdeploy is a platform for spinning up cloud based blockchains. Unrelated to dAppChains
JavaScript
43
star
12

plasma-cli

All In One stateful Plasma-Cash client, browser compatible
TypeScript
42
star
13

Etherboy

Etherboy in Blockchain world. A sample blockchain game that runs on a DAppchain.
C#
36
star
14

loom-sdk-documentation

Loom SDK Documentation Website
Shell
36
star
15

ethdeploy-client

EthDeploy - Client for deploying apps on the Ethdeploy private blockchain hosting
Go
31
star
16

transfer-gateway-example

Loom SDK Transfer Gateway ERC721 Example
JavaScript
31
star
17

loom-truffle-provider

Adapter that allows Truffle Suite to communicate with Loom DappChain
TypeScript
29
star
18

dashboard

Loom Basechain Gateway, wallet and DPoS UI / dashboard
Vue
28
star
19

tiles-chain

JavaScript
19
star
20

vue-block-explorer

Vue component for inspecting Loom DAppChains
TypeScript
18
star
21

blockscout

Elixir
18
star
22

soliditycookbook.com

CSS
18
star
23

weave-blueprint

Example Go Smart Contract project for Loom Blockchain
Go
18
star
24

loom-examples

Loom Examples
JavaScript
17
star
25

zb_game_mode

ZombiebBattleGround Game Modes in Solidity. For Extending the gameplay with custom game modes
Solidity
16
star
26

cocos-sdk

Cocos2d clientside integration
JavaScript
15
star
27

token-gateway-example

JavaScript
15
star
28

ethcontract

Ethutils for creating Ethereum Contracts in Golang. Related set of helpers
Go
15
star
29

phaser-sdk-demo

JavaScript
15
star
30

spores

Loom Network's all-in-one package to connect your client to your DApp on EthDeploy
JavaScript
14
star
31

etherboy-core

Etherboy Game Smart Contract for Loom DAppChain
Go
13
star
32

loom-js-samples

Sample code demonstrating usage of https://github.com/loomnetwork/loom-js
JavaScript
10
star
33

mamamerkle

Sparse Merkle Trees implementation
Go
10
star
34

unity-evm-blackjack

Unity Blackjack Demo of Loom SDK with EVM contracts
C#
8
star
35

solidityx.org

Python
7
star
36

unity3d-identity

Unity3d package for managing identities on Loom DAppChains
C#
5
star
37

Node.js-prototype

Node.js prototype
JavaScript
5
star
38

solidity-transfer-gateway

Transfer Gateway Solidity contracts for Ethereum & TRON
Go
4
star
39

loom-provider-json-rpc-proxy

Small proxy that proxies HTTP JSON RPC calls to Loomchain/EVM using LoomProvider under the hood
TypeScript
4
star
40

loom-identity-js

JS library for managing identities on Loom DAppChains.
TypeScript
4
star
41

loom-playbooks

Automation resources for Developers
4
star
42

loom-token

This repo contains smart contracts for the new LOOM ERC20 token, token swap, and staking system.
TypeScript
4
star
43

gamechain

Go
3
star
44

zombie-battleground-api

Public Api Docs for getting Zombie Battleground data, such as cards and matches
3
star
45

unity-tiles-chain-evm

C#
3
star
46

loom-cli

DPoS / Transfer Gateway CLI
TypeScript
3
star
47

homebrew-client

homebrew for osx for loom client
Ruby
3
star
48

loom-unity-project-template

C#
3
star
49

TimeLock

JavaScript
2
star
50

plasma-indexer

Syncs Go Smart Contract events from a Loom DAppChain to a MySQL DB
Go
2
star
51

go-transfer-gateway

Transfer Gateway Go contracts & Oracles
Go
2
star
52

dc-translations

DelegateCall i18N
1
star
53

truffle-loom-builder

Experimental Truffle built tool for easy integration with Loom
JavaScript
1
star
54

unity-sdk-docs

CSS
1
star
55

e2e

Test utility for Loom SDK
Go
1
star
56

zkloom-examples

Examples of deploying and interacting with contracts on zkLoom
TypeScript
1
star