Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add unity grpc client #105

Merged
merged 5 commits into from
Jan 16, 2024
Merged

Conversation

D4ryl00
Copy link
Contributor

@D4ryl00 D4ryl00 commented Jan 12, 2024

A gRPC .NET client with Unity.

It is part of #104

@D4ryl00 D4ryl00 self-assigned this Jan 12, 2024
Signed-off-by: D4ryl00 <[email protected]>
go run . tcp -addr 127.0.0.1:7042
```

In Unity Hab, import this folder.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Hab" should be "Hub".

`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()`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small grammar fix:
"is the script where lives the gRPC client"
should be
"is the script where the gRPC client lives"

Copy link
Contributor

@jefft0 jefft0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great. Minor comments.


We will copy the generated GnoNative API files and gRPC C# stubs in `Assets/Gno`.

In a terminal, write this command (remplace ${gnonative} by the location where is gnonative in your filesystem):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"remplace" should be "replace"


## Copy API dependencies

We will copy the generated GnoNative API files and gRPC C# stubs in `Assets/Gno`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"in" should be "into"


We will copy the generated GnoNative API files and gRPC C# stubs in `Assets/Gno`.

In a terminal, write this command (remplace ${gnonative} by the location where is gnonative in your filesystem):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest: "write this command" should be "cd to your Unity project folder and write this command"


```
In the `Start()` function, we initialize the gRPC client with the gRPC Web protocol and use the default GnoNative port.
In the `OnHello()` function, we do the `Hello` gRPC call and set the result into the `Text` object. This function can be trigger by a button for example.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"can be trigger" should be "can be triggered"


Now we have to attach these two objects to the script we wrote.

In the `Hierarchy` panel, select the button. Scroll down on the `Inspector` (right panel) to find the `On Click` section and click on `+` to add a new action. Drag and drop the `UI Script` object to the `None (Object)` in this action, and replace `No Function` by `Hello` -> `OnHello ()`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, Hello -> OnHello ()
should be
Hello.OnHello()

@D4ryl00 D4ryl00 merged commit d07ccc5 into gnolang:main Jan 16, 2024
@D4ryl00 D4ryl00 deleted the feat/unity-grpc-client branch January 16, 2024 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants