Skip to content

Commit

Permalink
Updating READMEs to add info on WebGL builds (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gekctek authored Jul 25, 2023
1 parent ed04ccf commit 5dff809
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ Collection of Internet Computer Protocol (ICP) libraries for .NET/Blazor/Unity

# 🎮 Unity Integration

Note: WebGL/IL2CPP is not supported YET due to an issue with IL2CPP, working on it
- Download latest binaries for the agent: https://github.com/edjCase/ICP.NET/releases
- Extract `.zip` to a plugins folder in your Unity Assets: `Assets/plugins/ICP.NET/`
- Download latest `agent.unitypackage` from: https://github.com/edjCase/ICP.NET/releases
- Import `agent.unitypackage` into your unity project
- If using WebGL, follow the additional WebGL instructions in the [Agent Docs](src/Agent/README.md)
- If generating a client (see below), place the generated files into the scripts folder: `Assets/scripts/MyClient`
- Start coding 💻

Expand Down
22 changes: 21 additions & 1 deletion src/Agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,24 @@ byte[] privateKey = ...;
DelegationChain chain = ...;
var innerIdentity = new Ed25519Identity(publicKeyBytes, privateKey);
var delegatedIdentity = new DelegationIdentity(innerIdentity, chain);
```
```

# WebGL Builds
Due to how WebGL works by converting C# to JS/WASM using IL2CPP there are a few additional steps to avoid
incompatibilities.
- UnityHttpClient - The .NET `HttpClient` does not work in many cases, so `UnityHttpClient` is added via Unity C# script.
```cs
var client = new UnityHttpClient();
var agent = new HttpAgent(client);
```
- WebGlBlsCryptography - The BLS signature verification relies on a 3rd party library and due to that library not being directly compatible with the WebGL builds, `WebGlBlsCryptography` needs to be used instead of the default `WasmBlsCryptography` class.

```cs
var bls = new WebGlBlsCrytography();
var agent = new HttpAgent(client, bls: bls);
```
In addition, the `bls.js` file located in `{icp.net base dir}/UnityAssets/` needs to be included in the Unity project and referenced by the HTML page
```html
<script src="{path_to_dir}/bls.js"/>
```
That will load in the JS bls library that will be referenced by the `Bls.jslib` that is included in the ICP.NET unity package

0 comments on commit 5dff809

Please sign in to comment.