docs.unity3d.com
Search Results for

    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
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    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.SetDirtyBit(uint)
    NetworkBehaviour.ClearAllDirtyBits()
    NetworkBehaviour.OnNetworkDestroy()
    NetworkBehaviour.OnStartServer()
    NetworkBehaviour.OnStartLocalPlayer()
    NetworkBehaviour.OnStartAuthority()
    NetworkBehaviour.OnStopAuthority()
    NetworkBehaviour.OnRebuildObservers(HashSet<NetworkConnection>, bool)
    NetworkBehaviour.OnSetLocalVisibility(bool)
    NetworkBehaviour.OnCheckObserver(NetworkConnection)
    NetworkBehaviour.GetNetworkChannel()
    NetworkBehaviour.GetNetworkSendInterval()
    MonoBehaviour.IsInvoking()
    MonoBehaviour.CancelInvoke()
    MonoBehaviour.Invoke(string, float)
    MonoBehaviour.InvokeRepeating(string, float, float)
    MonoBehaviour.CancelInvoke(string)
    MonoBehaviour.IsInvoking(string)
    MonoBehaviour.StartCoroutine(string)
    MonoBehaviour.StartCoroutine(string, object)
    MonoBehaviour.StartCoroutine(IEnumerator)
    MonoBehaviour.StartCoroutine_Auto(IEnumerator)
    MonoBehaviour.StopCoroutine(IEnumerator)
    MonoBehaviour.StopCoroutine(Coroutine)
    MonoBehaviour.StopCoroutine(string)
    MonoBehaviour.StopAllCoroutines()
    MonoBehaviour.print(object)
    MonoBehaviour.useGUILayout
    MonoBehaviour.runInEditMode
    Behaviour.enabled
    Behaviour.isActiveAndEnabled
    Component.GetComponent(Type)
    Component.GetComponent<T>()
    Component.TryGetComponent(Type, out Component)
    Component.TryGetComponent<T>(out T)
    Component.GetComponent(string)
    Component.GetComponentInChildren(Type, bool)
    Component.GetComponentInChildren(Type)
    Component.GetComponentInChildren<T>(bool)
    Component.GetComponentInChildren<T>()
    Component.GetComponentsInChildren(Type, bool)
    Component.GetComponentsInChildren(Type)
    Component.GetComponentsInChildren<T>(bool)
    Component.GetComponentsInChildren<T>(bool, List<T>)
    Component.GetComponentsInChildren<T>()
    Component.GetComponentsInChildren<T>(List<T>)
    Component.GetComponentInParent(Type)
    Component.GetComponentInParent<T>()
    Component.GetComponentsInParent(Type, bool)
    Component.GetComponentsInParent(Type)
    Component.GetComponentsInParent<T>(bool)
    Component.GetComponentsInParent<T>(bool, List<T>)
    Component.GetComponentsInParent<T>()
    Component.GetComponents(Type)
    Component.GetComponents(Type, List<Component>)
    Component.GetComponents<T>(List<T>)
    Component.GetComponents<T>()
    Component.CompareTag(string)
    Component.SendMessageUpwards(string, object, SendMessageOptions)
    Component.SendMessageUpwards(string, object)
    Component.SendMessageUpwards(string)
    Component.SendMessageUpwards(string, SendMessageOptions)
    Component.SendMessage(string, object)
    Component.SendMessage(string)
    Component.SendMessage(string, object, SendMessageOptions)
    Component.SendMessage(string, SendMessageOptions)
    Component.BroadcastMessage(string, object, SendMessageOptions)
    Component.BroadcastMessage(string, object)
    Component.BroadcastMessage(string)
    Component.BroadcastMessage(string, SendMessageOptions)
    Component.transform
    Component.gameObject
    Component.tag
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(object)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, bool)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, bool)
    Object.Destroy(Object, float)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, bool)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, float)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    Object.FindObjectOfType<T>()
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.ToString()
    Object.name
    Object.hideFlags
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: UnityEngine.Networking
    Assembly: com.unity.multiplayer-hlapi.Runtime.dll
    Syntax
    [DisallowMultipleComponent]
    [AddComponentMenu("Network/NetworkLobbyPlayer")]
    [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
    [Tooltip("Enable to show the default lobby GUI for this player.")]
    [SerializeField]
    public bool ShowLobbyGUI
    Field Value
    Type Description
    bool

    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
    bool

    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
    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(bool)

    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
    bool readyState

    Whether the player is ready or not.

    OnDeserialize(NetworkReader, bool)

    Virtual function to override to receive custom serialization data. The corresponding function to send serialization data is OnSerialize().

    Declaration
    public override void OnDeserialize(NetworkReader reader, bool initialState)
    Parameters
    Type Name Description
    NetworkReader reader

    Reader to read from the stream.

    bool initialState

    True if being sent initial state.

    Overrides
    NetworkBehaviour.OnDeserialize(NetworkReader, bool)

    OnSerialize(NetworkWriter, bool)

    Virtual function to override to send custom serialization data. The corresponding function to send serialization data is OnDeserialize().

    The initialState flag is useful to differentiate between the first time an object is serialized and when incremental updates can be sent. The first time an object is sent to a client, it must include a full state snapshot, but subsequent updates can save on bandwidth by including only incremental changes. Note that SyncVar hook functions are not called when initialState is true, only for incremental updates.

    If a class has SyncVars, then an implementation of this function and OnDeserialize() are added automatically to the class. So a class that has SyncVars cannot also have custom serialization functions.

    The OnSerialize function should return true to indicate that an update should be sent. If it returns true, then the dirty bits for that script are set to zero, if it returns false then the dirty bits are not changed. This allows multiple changes to a script to be accumulated over time and sent when the system is ready, instead of every frame.

    Declaration
    public override bool OnSerialize(NetworkWriter writer, bool initialState)
    Parameters
    Type Name Description
    NetworkWriter writer

    Writer to use to write to the stream.

    bool initialState

    If this is being called to send initial state.

    Returns
    Type Description
    bool

    True if data was written.

    Overrides
    NetworkBehaviour.OnSerialize(NetworkWriter, bool)

    OnStartClient()

    Called on every NetworkBehaviour when it is activated on a client.

    Objects on the host have this function called, as there is a local client on the host. The values of SyncVars on object are guaranteed to be initialized correctly with the latest state from the server when this function is called on the client.

    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()
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)