Skip to content

Commit

Permalink
chore: add README
Browse files Browse the repository at this point in the history
Signed-off-by: D4ryl00 <[email protected]>
  • Loading branch information
D4ryl00 committed Jan 15, 2024
1 parent b96469b commit 7bef0eb
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions examples/UnityClient/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# gRPC .NET client with Unity

This example folder implements a
[.NET gRPC](https://github.com/grpc/grpc-dotnet) client with Unity.

## Usage

In a terminal, go to `gnonative/goserver` and run the gRPC server:

```bash
go run . tcp -addr 127.0.0.1:7042
```

In Unity Hab, import this folder.

In Unity, select the `SampleScene` in `Assets/Scenes`. Play the project, click
on the button and look at the result in the text object.

## Structure

`Assets/Scenes/SampleScene.unity` is the Unity scene we use for the demo. We
implemented a button to start an action, and a text object to print the result.

`Assets/GnoClient.cs` is the script where lives the gRPC client. The `Start()`
method initializes the client on a fixed local port (`7042`). When you click on
the button object on the scene, the `OnHello` method calls the gRPC `Hello` call
and print the result on the text object.

`Assets/Gno` contains a copy of the generated GnoNative API files and gRPC C#
stubs (`api/gen/csharp`).

## Nuget package management

The gRPC .NET client is avalaible through the Nuget ecosystem. Unity doesn't
support it natively, so we had to add a module
([NuGetForUnity](https://github.com/GlitchEnzo/NuGetForUnity)) to be able to
install it easily. We installed the `Grpc.Net.Client` family packages.

0 comments on commit 7bef0eb

Please sign in to comment.