LogoLogo
  • SWNetwork SDK Overview
  • Installation
    • Custom Unity Package
  • Tutorials
    • Third-Person Shooter
      • Starter Project Introduction
      • Install SWNetwork
      • Setting up the NetworkClient
      • Sync Player Transform
      • Setting up the Scene Spawner
      • Test and Play
      • Remote Events
      • SyncProperties
      • Player Respawn
      • Updating Room States
      • Winning the Game
    • Basic Lobby
      • Lobby-start
      • Installing SWNetwork SDK and configuring NetworkClient
      • Registering Player
      • Room CRUD
      • Managing Teams
      • Chat
  • SDK
    • Network Client
      • Check-in
      • Game Servers
      • Network Status Event (beta)
      • Classes
        • NetworkClient Class
      • Methods
        • CheckIn() Method
        • ConnectToRoom(Action<bool>) Method
        • DisconnectFromRoom () Method
        • FindSpawner(ushort) Method
    • Game Play
      • Network ID
      • Realtime Agent
      • Remote Event
      • Sync Property
        • Restore Sync Properties
        • Conflict Resolution
      • SceneSpawner
      • RoomPropertyAgent
      • RoomRemoteEventAgent
    • Lobby
      • Register Player
      • Message Player
      • Create Room
      • Change Room Settings
      • Get Rooms
      • Filter Rooms
      • Join Room
      • Message Room
      • Get Players in Room
      • Get Room Custom Data
      • Change Room Custom Data
      • Kick Players
      • Start Room
      • Leave Room
      • Lobby Room Events
        • OnLobbyConnectedEvent
        • OnPlayerMessageEvent
        • OnRoomCustomDataChangeEvent
        • OnNewPlayerJoinRoomEvent
        • OnPlayerLeaveRoomEvent
        • OnNewRoomOwnerEvent
        • OnRoomStartingEvent
        • OnRoomReadyEvent
        • OnFailedToStartRoomEvent
        • OnKickedEvent
        • OnRoomMessageEvent
      • Classes
        • SWLobby Class
        • SWPlayer Class
        • SWRoom Class
        • SWRegisterReply Class
        • SWGetRoomReply Class
        • SWJoinRoomReply Class
        • SWGetRoomCustomDataReply Class
        • SWGetPlayersReply Class
        • SWLobbyIndexData Class
        • SWLobbyFilterData Class
        • SWGetRoomFilterReply Class
        • SWLobbyError Class
        • SWMessagePlayerEventData Class
        • SWMessageRoomEventData Class
        • SWRoomCustomDataChangeEventData Class
        • SWJoinRoomEventData Class
        • SWLeaveRoomEventData Class
        • SWRoomChangeOwnerEventData Class
        • SWStartRoomEventData Class
        • SWRoomReadyEventData Class
        • SWFailedToStartRoomEventData Class
      • Methods
        • Register(Action<bool, SWRegisterReply, SWLobbyError>) Method
        • MessagePlayer(string, string, Action<bool, SWLobbyError>) Method
        • CreateRoom(bool, int, Action<bool, string, SWLobbyError>) Method
        • ChangeRoomSettings(int, int, Action<bool, SWLobbyError>) Method
        • GetRooms(int, int, Action<bool, SWGetRoomReply, SWLobbyError>) Method
        • FilterRoom(SWLobbyFilterData, byte, Action<bool, SWGetRoomFilterReply, SWLobbyError>) Method
        • JoinRoom(string, Action<bool, SWJoinRoomReply, SWLobbyError>) Method
        • JoinRoomRandomly(Action<bool, SWJoinRoomReply, SWLobbyError>) Method
        • JoinOrCreateRoom(bool, int, int, Action<bool, SWJoinRoomReply, SWLobbyError>) Method
        • MessageRoom(string, Action<bool, SWLobbyError>) Method
        • GetRoomCustomData(Action<bool, SWGetRoomCustomDataReply, SWLobbyError>) Method
        • GetPlayersInRoom(Action<bool, SWGetPlayersReply, SWLobbyError>) Method
        • ChangeRoomCustomData(string, Action<bool, SWLobbyError>) Method
        • StartRoom(Action<bool, SWLobbyError>) Method
        • LeaveRoom(Action<bool, SWLobbyError>) Method
  • Open Source Software Used
    • Credits
Powered by GitBook
On this page
  • Project Introduction
  • Modeling Your Custom Room Data

Was this helpful?

  1. Tutorials
  2. Basic Lobby

Lobby-start

Project Introduction

The project contains a single scene which serves as the Lobby interface. The GUI events are already hooked up in the editor for you.

The Lobby interface is divided into 3 parts: The header, the left panel, and the right panel.

Header UI elements

Register button

Will be used to register the local player to the lobby server.

Click on the button will invoke the RegisterPlayer() method of the LobbyDemo object.

Create room button

Will be used to create new room.

Click on the button will invoke the CreateNewRoom() method of the LobbyDemo object.

Leave room button

Will be used to leave the local player's current room.

Click on the button will invoke the LeaveRoom() method of the LobbyDemo object.

Left panel UI elements

Previous button

Will be used to load the rooms on the previous page.

Click on the button will invoke the PreviousPage() method of the LobbyDemo object.

Refresh button

Will be used to re-load the rooms on the current page.

Click on the button will invoke the GetRooms() method of the LobbyDemo object.

Next button

Will be used to load the rooms on the next page.

Click on the button will invoke the NextPage() method of the LobbyDemo object.

Rooms list

Will be used to display the rooms on the current page.

Right panel UI elements

Players list

Will be used to display the players in local player's current room.

Room chat list

Will be used to display chat messages.

Room chat input field

Will be used to enter new room chat messages.

Press enter will invoke the SendRoomMessage(string) method of the LobbyDemo object.

Modeling Your Custom Room Data

In this tutorial, we want to separate players in a room to 2 teams. We created TeamCustomData to keep track of players in a team and RoomCustomData to keep track of teams of the room.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;

[Serializable]
public class RoomCustomData
{
    public string name;
    public TeamCustomData team1;
    public TeamCustomData team2;
}

[Serializable]
public class TeamCustomData
{
    // Stores playerIds, so players knows which team they are on.
    public List<string> players = new List<string>();
}

In the next steps, we will integrate SWNetwork.Lobby APIs to make the scene come to live.

PreviousBasic LobbyNextInstalling SWNetwork SDK and configuring NetworkClient

Last updated 5 years ago

Was this helpful?