mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
doc: fixed example code to use struct with NetworkMessage
This commit is contained in:
parent
43cea98ef9
commit
7de02aef55
@ -56,18 +56,18 @@ This will create a script in your project with 2 empty message classes and a cus
|
||||
The message classes define what is sent between the client and server. As long as you keep your messages simple using the [data types](../Guides/DataTypes.md) that Mirror can serialize, you won't need to write custom serializers for them.
|
||||
|
||||
```cs
|
||||
public class DiscoveryRequest : NetworkMessage
|
||||
public struct DiscoveryRequest : NetworkMessage
|
||||
{
|
||||
public string language="en";
|
||||
public string language;
|
||||
|
||||
// Add properties for whatever information you want sent by clients
|
||||
// in their broadcast messages that servers will consume.
|
||||
}
|
||||
|
||||
public class DiscoveryResponse : NetworkMessage
|
||||
{
|
||||
enum GameMode {PvP, PvE};
|
||||
enum GameMode {PvP, PvE};
|
||||
|
||||
public struct DiscoveryResponse : NetworkMessage
|
||||
{
|
||||
// you probably want uri so clients know how to connect to the server
|
||||
public Uri uri;
|
||||
|
||||
|
@ -19,7 +19,7 @@ and use it as your Network manager.
|
||||
3) Create a message that describes your player. For example:
|
||||
|
||||
``` cs
|
||||
public class CreateMMOCharacterMessage : NetworkMessage
|
||||
public struct CreateMMOCharacterMessage : NetworkMessage
|
||||
{
|
||||
public Race race;
|
||||
public string name;
|
||||
|
Loading…
Reference in New Issue
Block a user