Version: 2017.1
Network Lobby Manager


The NetworkIdentity component is a Unity component that is at the heart of the new networking system. It can be added to objects from the AddComponents->Network->NetworkIdentity menu item. This component controls an object’s network identity, and it makes the networking system aware of it. This shows what the NetworkIdentity component looks like on an object:

With the server authoritative system of the Unity Network System, networked objects with NetworkIdentities must be “spawned” by the server using NetworkServer.Spawn(). This causes them to be assigned a NetworkInstanceId and be created on clients that are connected to the server.

Scene objects are treated a bit differently than dynamically instantiated objects. These objects are all present in the scene on both client and server. However, when building the game all the scene objects with network identities are disabled. When the client connects to the server the server tells the client which scene objects should be enabled and what their most up to date state information is through spawn messages. This ensures the client will not contain objects placed at now incorrect locations when they start playing, or even objects which will be deleted immediately on connection because some event removed them before the client connected. The Server Only checkbox will ensure this a particular object will not be spawned or enabled on clients.

The local player authority setting allows this object to be controlled by the client that owns it - the local player object on that client has authority over it. This is used by other components such as NetworkTransform.

This component contains tracking information like what scene ID, network ID and asset ID the object has been assigned. The scene ID is valid in all scene objects with a NetworkIdentity component. The network ID is the ID of this particular object instance, there might be multiple objects instantiated of a particular object type and the network ID is used to identity which object, for example, a network update should be applied to. The asset ID refers to what source asset the object was instantiated from. This is used internally when an particular object prefab is spawned over the network. This information is exposed in the preview panel at the bottom of the inspector:

在运行时,此处将显示更多信息(禁用的 NetworkBehaviour 以非粗体显示):


属性: 功能:
assetId 标识与此对象关联的预制件(用于生成)。
clientAuthorityOwner 对该对象拥有授权的客户端。如果没有客户端拥有授权,则此属性为 null。
connectionToClient The connection associated with this NetworkIdentity. This is only valid for player objects on the server.
connectionToServer The UConnection associated with this NetworkIdentity. This is only valid for player objects on a local client.
hasAuthority True if this object is the authoritative version of the object. So either on a the server, or on the client with localPlayerAuthority.
isClient 如果此对象在客户端上运行,则为 true。
isLocalPlayer 如果此对象代表本地计算机上的玩家,则返回 true。
isServer 如果此对象在服务器上运行并且已生成,则为 true。
localPlayerAuthority 如果此对象由拥有此对象的客户端控制,则为 true - 该客户端上的本地玩家对象具有针对此对象的授权。由 NetworkTransform 等其他组件使用。
netId 此网络会话的唯一标识符,在生成时分配。
observers 能够看到此对象的客户端 NetworkConnection 列表。此属性为只读。
playerControllerId 与此对象关联的控制器的标识符。仅对玩家对象有效。
sceneId A unique identifier for networked objects in a scene. This is only populated in play-mode.
serverOnly 此标志用于指示不在客户端上生成该对象。


  • Put a NetworkIdentity component on prefabs that will be spawned.
  • A NetworkIdentity is required for every object that is networked.
Network Lobby Manager