1. Home
  2. Unity RTS Engine
  3. Multiplayer Menu
  4. Network Manager (UNET)

Network Manager (UNET)

Before digging into the fields of the NetworkManager_UNET component, it is worth noting that the canvas object and all UI elements are children of the “MultiplayerManager_UNET” object.

In addition to discussing the component’s fields, other UI elements that are do not belong to any field in the component will also be discussed as they include events that help shape the multiplayer menu. These will be marked with “non-field” to avoid confusion.


General:

 

  1. Main Menu Scene: The name of the scene that you want the player to get back to from the the multiplayer menu.
  2. Canvas Obj: The canvas that holds all the UI menus for the multiplayer menu.
  3. Game Version: Input the current version of the game here.
  4. Game Version Text: This is a UI Text that will display the player’s game version.

Main MP Menu:

  1. Main MP Menu: The main multiplayer menu which appears when the scene first loads and from where you can access the other menus (LAN menu, matchmaking menu, etc…).

Matchmaking Menu:

  1. Match Making Menu: The menu that allows the player to create an online match or join one.
  2. Internet Match Name: A UI Inputfield that is used to input the faction’s name. In the “On End Edit” event of the “InputField” component, drag and drop the object that has the NetworkManager_UNET component as the event source and set the event to NetworkManager_UNET -> “SetInternetMatchName”.
  3. Internet Match Size: A UI Inputfield that is used to input the faction’s name. In the “On End Edit” event of the “InputField” component, drag and drop the object that has the NetworkManager_UNET component as the event source and set the event to NetworkManager_UNET”-> “SetMatchSize”.
  4. Internet Match Max Size: The maximum amount of factions allowed to be in one room at the same time.
  5. Create Internet Match Button (non-field): A UI Button that creates the internet match to allow others to join. In the “On Click” event of the “Button” component, drag and drop the object that has the NetworkManager_UNET component as the event source and set the event to NetworkManager_UNET -> “StartInternetMatch”.
  6. Match Button Prefab: For each internet match found, this object will be spawned. This prefab is a UI object that includes the InternetMatch_UNET component and has UI child objects that shows the match’s name (UI Text in the “Match Name” field) and the match’s size (another UI Text in the “Match Size” field). This prefab also includes, as a child object, a UI Button that allows the player to join the internet match. In the “On Click” event of the “Button” component, drag and drop the Match Button Prefab as the event source and set the event to InternetMatch_UNET -> “JoinInternetMatch”.
  7. Matches Parent: UI object, parent of the internet match buttons (the prefab in the field just above). In order to organize the internet matches and display them correctly, it’s recommended to have a “Grid Layout Group” component on this object.

Loading Menu:

  1. Loading Menu: This menu is shown when the player joins a match and is waiting to connect to the room.
  2. Info Msg: A UI Text that shows a message whenever there’s an error/warning (it is recommended to not have this a child of any of the above menus).

Lobby Menu:

  1. Lobby Menu: The menu that is shown when the player joins a room:
  2. Lobby Player Parent: UI object, parent of all Lobby Player objects. Each child object represents a faction slot. In order to organise the faction slots and display them correctly, it’s recommended to have a “Grid Layout Group” component on this object.
  3. Allowed Colors: A list of the colors that a faction is allowed to have.

Map Menu (host only):

  1. Host Map Menu: The menu that allows the host to pick a map. It displayed for all clients but only the host can modify its content (interact with the UI elements inside of it).
  2. Room Name: A UI Text that shows the room’s name.
  3. Maps: A list that holds all the maps that can be used in a multiplayer game. For each map, a couple of settings need to be defined:
    1. Map Scene: Name of the map’s scene.
    2. Map Name: Name of the map to show in the UI menu.
    3. Map Description: When a map is selected, this description is displayed.
    4. Max Factions: Maximum amount of factions that this map supports.
    5. Initial Population: The initial amount of population for the factions in this map.
    6. Faction Types: A list of Faction Type Info assets that define the possible faction types that can play in the map.
  4.  Map Drop Down Menu: A UI Dropdown that allows the host to pick a map from a list of possible options. In the “On Value Changed” event of the “Dropdown” component, drag and drop the object that has the drag and drop the object that has the NetworkManager_UNET component as the event source and set the event to NetworkManager_UNET -> “UpdateMapSettings”.
  5. Initial Population: A UI Text to display the selected map’s initial amount of population slots.
  6. Map Description: A UI Text that shows the selected map’s description.
  7. Map Max Factions: A UI Text that shows the selected map’s maximum allowed amount of factions.
  8. Start Game Button: A UI Button that is only shown for the room’s host. In the “On Click” event of the “Button” component, drag and drop the object that has the NetworkManager_UNET component as the event source and set the event to NetworkManager_UNET -> “StartGame”. This is displayed only for the host as he’s the only one able to start the game once all the players are marked as ready.

Network Discovery:

  1. Discovery: In order to allow multiple computers in a local network to recongize and discover each other, we need the Network Discovery component. Therefore you need to have the NetDiscovery_UNET component (which is inherited from the “NetworkDiscovery” component) on the “MultiplayerManager_UNET” object. Then drag and drop that in this field. You don’t need to modify anything in the inspector of that component.
  2. Use Discovery: Enable/disable the use of network discovery in LAN games with this field.

Other elements of the multiplayer menu UI:

  1. Back Button (non field): A UI Button (must not be a child of any of the above menus) that takes the player back to the last menu he was in. In the “On Click” event of the “Button” component, drag and drop the object that has the NetworkManager_UNET component as the event source and set the event to NetworkManager_UNET -> “MainMenu”.

How can we help?