Class NetworkLobbyPlayer | Package Manager UI website
docs.unity3d.com
    Show / Hide Table of Contents

    Class NetworkLobbyPlayer

    This component works in conjunction with the NetworkLobbyManager to make up the multiplayer lobby system.

    The LobbyPrefab object of the NetworkLobbyManager must have this component on it. This component holds basic lobby player data required for the lobby to function. Game specific data for lobby players can be put in other components on the LobbyPrefab or in scripts derived from NetworkLobbyPlayer.

    Inheritance
    System.Object
    NetworkBehaviour
    NetworkLobbyPlayer
    Inherited Members
    NetworkBehaviour.localPlayerAuthority
    NetworkBehaviour.isServer
    NetworkBehaviour.isClient
    NetworkBehaviour.isLocalPlayer
    NetworkBehaviour.hasAuthority
    NetworkBehaviour.netId
    NetworkBehaviour.connectionToServer
    NetworkBehaviour.connectionToClient
    NetworkBehaviour.playerControllerId
    NetworkBehaviour.syncVarDirtyBits
    NetworkBehaviour.syncVarHookGuard
    NetworkBehaviour.SendCommandInternal(NetworkWriter, Int32, String)
    NetworkBehaviour.InvokeCommand(Int32, NetworkReader)
    NetworkBehaviour.SendRPCInternal(NetworkWriter, Int32, String)
    NetworkBehaviour.SendTargetRPCInternal(NetworkConnection, NetworkWriter, Int32, String)
    NetworkBehaviour.InvokeRPC(Int32, NetworkReader)
    NetworkBehaviour.SendEventInternal(NetworkWriter, Int32, String)
    NetworkBehaviour.InvokeSyncEvent(Int32, NetworkReader)
    NetworkBehaviour.InvokeSyncList(Int32, NetworkReader)
    NetworkBehaviour.RegisterCommandDelegate(Type, Int32, NetworkBehaviour.CmdDelegate)
    NetworkBehaviour.RegisterRpcDelegate(Type, Int32, NetworkBehaviour.CmdDelegate)
    NetworkBehaviour.RegisterEventDelegate(Type, Int32, NetworkBehaviour.CmdDelegate)
    NetworkBehaviour.RegisterSyncListDelegate(Type, Int32, NetworkBehaviour.CmdDelegate)
    NetworkBehaviour.SetSyncVarGameObject(GameObject, GameObject, UInt32, NetworkInstanceId)
    NetworkBehaviour.SetSyncVar<T>(T, T, UInt32)
    NetworkBehaviour.SetDirtyBit(UInt32)
    NetworkBehaviour.ClearAllDirtyBits()
    NetworkBehaviour.PreStartClient()
    NetworkBehaviour.OnNetworkDestroy()
    NetworkBehaviour.OnStartServer()
    NetworkBehaviour.OnStartLocalPlayer()
    NetworkBehaviour.OnStartAuthority()
    NetworkBehaviour.OnStopAuthority()
    NetworkBehaviour.OnRebuildObservers(HashSet<NetworkConnection>, Boolean)
    NetworkBehaviour.OnSetLocalVisibility(Boolean)
    NetworkBehaviour.OnCheckObserver(NetworkConnection)
    NetworkBehaviour.GetNetworkChannel()
    NetworkBehaviour.GetNetworkSendInterval()
    Namespace: UnityEngine.Networking
    Syntax
    [Obsolete("The high level API classes are deprecated and will be removed in the future.")]
    public class NetworkLobbyPlayer : NetworkBehaviour

    Fields

    ShowLobbyGUI

    This flag controls whether the default UI is shown for the lobby player.

    As this UI is rendered using the old GUI system, it is only recommended for testing purposes.

    Declaration
    public bool ShowLobbyGUI
    Field Value
    Type Description
    System.Boolean

    Properties

    readyToBegin

    This is a flag that control whether this player is ready for the game to begin.

    When all players are ready to begin, the game will start. This should not be set directly, the SendReadyToBeginMessage function should be called on the client to set it on the server.

    Declaration
    public bool readyToBegin { get; set; }
    Property Value
    Type Description
    System.Boolean

    slot

    The slot within the lobby that this player inhabits.

    Lobby slots are global for the game - each player has a unique slotId.

    Declaration
    public byte slot { get; set; }
    Property Value
    Type Description
    System.Byte

    Methods

    OnClientEnterLobby()

    This is a hook that is invoked on all player objects when entering the lobby.

    Note: isLocalPlayer is not guaranteed to be set until OnStartLocalPlayer is called.

    Declaration
    public virtual void OnClientEnterLobby()

    OnClientExitLobby()

    This is a hook that is invoked on all player objects when exiting the lobby.

    Declaration
    public virtual void OnClientExitLobby()

    OnClientReady(Boolean)

    This is a hook that is invoked on clients when a LobbyPlayer switches between ready or not ready.

    This function is called when the a client player calls SendReadyToBeginMessage() or SendNotReadyToBeginMessage().

    Declaration
    public virtual void OnClientReady(bool readyState)
    Parameters
    Type Name Description
    System.Boolean readyState

    Whether the player is ready or not.

    OnDeserialize(NetworkReader, Boolean)

    Declaration
    public override void OnDeserialize(NetworkReader reader, bool initialState)
    Parameters
    Type Name Description
    NetworkReader reader
    System.Boolean initialState
    Overrides
    NetworkBehaviour.OnDeserialize(NetworkReader, Boolean)

    OnSerialize(NetworkWriter, Boolean)

    Declaration
    public override bool OnSerialize(NetworkWriter writer, bool initialState)
    Parameters
    Type Name Description
    NetworkWriter writer
    System.Boolean initialState
    Returns
    Type Description
    System.Boolean
    Overrides
    NetworkBehaviour.OnSerialize(NetworkWriter, Boolean)

    OnStartClient()

    Declaration
    public override void OnStartClient()
    Overrides
    NetworkBehaviour.OnStartClient()

    RemovePlayer()

    This removes this player from the lobby.

    This player object will be destroyed - on the server and on all clients.

    Declaration
    public void RemovePlayer()

    SendNotReadyToBeginMessage()

    This is used on clients to tell the server that this player is not ready for the game to begin.

    Declaration
    public void SendNotReadyToBeginMessage()

    SendReadyToBeginMessage()

    This is used on clients to tell the server that this player is ready for the game to begin.

    Declaration
    public void SendReadyToBeginMessage()

    SendSceneLoadedMessage()

    This is used on clients to tell the server that the client has switched from the lobby to the GameScene and is ready to play.

    This message triggers the server to replace the lobby player with the game player.

    Declaration
    public void SendSceneLoadedMessage()
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023