Search Unity

Network Lobby Manager API

Discussion in 'Multiplayer' started by Zoford, Jun 22, 2017.

  1. Zoford

    Zoford

    Joined:
    Mar 1, 2017
    Posts:
    13
    Hey everyone, I am having trouble creating a Network Lobby Manager script that uses my own UI and not the prebuilt one.Thanks you for your help.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Networking;
    5.  
    6. public class LobbyManager : NetworkLobbyManager{
    7.  
    8.     void Update () {
    9.     /*
    10.         if (Sumbit InputField){
    11.             Set PlayerName to InputField value.
    12.             Then add the player to the server and mark as ready.
    13.         }
    14.     */
    15.     }
    16.  
    17.     // The OnClick() function of the HOST button will call this.
    18.     public void hostGame(){
    19.         // I need this to change the scene to Lobby and establish this client as Host.
    20.     }
    21.  
    22.     // The OnClick() function of the JOIN button will call this.
    23.     public void joinGame(){
    24.         // I need this to change the scene to Lobby and join a existing random lobby.
    25.     }
    26. }
    27.  
     
  2. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    try to get the singleton and call StartHost().
    Then on the JoinGame ge the singleton, set the network address,networkport and StartClient().

    AFAIK the LobbyManager just derives from NetworkManager

    Edit: Since you derive from NetworkLobbyManager. You are the singleton. So just do this.StartHost(); and this.StartClient();
     
    Last edited: Jun 22, 2017