Method group is Obsolete

NetworkServer

class in UnityEngine.Networking

Cambiar al Manual
Obsolete

Descripción

The NetworkServer uses a NetworkServerSimple for basic network functionality and adds more game-like functionality.

NetworkServer handles remote connections from remote clients via a NetworkServerSimple instance, and also has a local connection for a local client.

The NetworkServer is a singleton. It has static convenience functions such as NetworkServer.SendToAll() and NetworkServer.Spawn() which automatically use the singleton instance.

The NetworkManager uses the NetworkServer, but it can be used without the NetworkManager.

The set of networked objects that have been spawned is managed by NetworkServer. Objects are spawned with NetworkServer.Spawn() which adds them to this set, and makes them be created on clients. Spawned objects are removed automatically when they are destroyed, or than they can be removed from the spawned set by calling NetworkServer.UnSpawn() - this does not destroy the object.

There are a number of internal messages used by NetworkServer, these are setup when NetworkServer.Listen() is called.

Funciones Estáticas

AddPlayerForConnectionWhen an AddPlayer message handler has received a request from a player, the server calls this to associate the player object with the connection.
BecomeHostThis allows a client that has been disconnected from a server, to become the host of a new version of the game.
ReplacePlayerForConnectionThis replaces the player object for a connection with a different player object. The old player object is not destroyed.
SendBytesToReadyThis sends an array of bytes to all ready players.
SendToAllSend a message structure with the given type number to all connected clients.
SendToClientSend a message to the client which owns the given connection ID.
SendToClientOfPlayerSend a message to the client which owns the given player object instance.
SendToReadySend a message structure with the given type number to only clients which are ready.
SendUnreliableToAllSend given message structure as an unreliable message to all connected clients.
SendUnreliableToReadySend given message structure as an unreliable message only to ready clients.
SendWriterToReadySends the contents of a NetworkWriter object to the ready players.
SpawnSpawn the given game object on all clients which are ready.
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961