Version: 5.3 (switch to 5.4b)
IdiomaEnglish
  • C#
  • JS

Idioma de script

Selecciona tu lenguaje de programación favorito. Todos los fragmentos de código serán mostrados en este lenguaje.

ClientScene

class in UnityEngine.Networking

Sugiere un cambio

¡Éxito!

Gracias por ayudarnos a mejorar la calidad de la documentación de Unity. A pesar de que no podemos aceptar todas las sugerencias, leemos cada cambio propuesto por nuestros usuarios y actualizaremos los que sean aplicables.

Cerrar

No se puedo enviar

Por alguna razón su cambio sugerido no pudo ser enviado. Por favor <a>intente nuevamente</a> en unos minutos. Gracias por tomarse un tiempo para ayudarnos a mejorar la calidad de la documentación de Unity.

Cerrar

Cancelar

Cambiar al Manual

Descripción

A client manager which contains static client information and functions.

This manager contains references to tracked static local objects such as spawner registrations. It also has the default message handlers used by clients when they registered none themselves. The manager handles adding/removing player objects to the game after a client connection has been set as ready.

The ClientScene is a singleton, and it has static convenience methods such as ClientScene.Ready().

The ClientScene is used by the NetworkManager, but it can be used by itself.

As the ClientScene manages player objects on the client, it is where clients request to add players. The NetworkManager does this via the ClientScene automatically when auto-add-players is set, but it can be done through code using the function ClientScene.AddPlayer(). This sends an AddPlayer message to the server and will cause a player object to be created for this client.

Like NetworkServer, the ClientScene understands the concept of the local client. The function ClientScene.ConnectLocalServer() is used to become a host by starting a local client (when a server is already running).

Variables Estáticas

localPlayersA list of all players added to the game.
objectsThis is a dictionary of networked objects that have been spawned on the client.
prefabsThis is a dictionary of the prefabs that are registered on the client with ClientScene.RegisterPrefab().
readyReturns true when a client's connection has been set to ready.
readyConnectionThe NetworkConnection object that is currently "ready". This is the connection to the server where objects are spawned from.
reconnectIdThe reconnectId to use when a client reconnects to the new host of a game after the old host was lost.
ReconnectIdHostA constant ID used by the old host when it reconnects to the new host.
ReconnectIdInvalidAn invalid reconnect Id.
spawnableObjectsThis is dictionary of the disabled NetworkIdentity objects in the scene that could be spawned by messages from the server.

Funciones Estáticas

AddPlayerThis adds a player object for this client. This causes an AddPlayer message to be sent to the server, and NetworkManager.OnServerAddPlayer will be called. If an extra message was passed to AddPlayer, then OnServerAddPlayer will be called with a NetworkReader that contains the contents of the message.
ClearSpawnersThis clears the registered spawn prefabs and spawn handler functions for this client.
ConnectLocalServerCreate and connect a local client instance to the local server. This makes the client into a "host" - a client and server in the same process.
DestroyAllClientObjectsDestroys all networked objects on the client.
FindLocalObjectThis finds the local NetworkIdentity object with the specified network Id.
ReadySignal that the client connection is ready to enter the game.
RegisterPrefabRegisters a prefab with the UNET spawning system.
RegisterSpawnHandlerThis is an advanced spawning funciotn that registers a custom assetId with the UNET spawning system.
RemovePlayerRemove the specified player ID from the game.
SetLocalObjectNetId is a unique number assigned to all objects with NetworkIdentity components in a game.
SetReconnectIdSets the Id that the ClientScene will use when reconnecting to a new host after host migration.
UnregisterPrefabRemoves a registered spawn prefab that was setup with ClientScene.RegisterPrefab.
UnregisterSpawnHandlerRemoves a registered spawn handler function that was registered with ClientScene.RegisterHandler().