The network class is at the heart of the network implementation and provides the core functions.
This class configures the network interface and all the network parameters. You use it to set up a server or connect to one and have a row of helper functions to help you with those tasks. For more information on what is exposed in the editor see the Network Manger component reference.
OnPlayerConnected |
Called on the server whenever a new player has successfully connected. |
OnServerInitialized |
Called on the server whenever a Network.InitializeServer was invoked and has completed. |
OnConnectedToServer |
Called on the client when you have successfully connected to a server. |
OnPlayerDisconnected |
Called on the server whenever a player is disconnected from the server. |
OnDisconnectedFromServer |
Called on client during disconnection from server, but also on the server when the connection has disconnected. |
OnFailedToConnect |
Called on the client when a connection attempt fails for some reason. |
OnNetworkInstantiate |
Called on objects which have been network instantiated with Network.Instantiate. |
OnSerializeNetworkView |
Used to customize synchronization of variables in a script watched by a network view. |
incomingPassword |
Set the password for the server (for incoming connections). |
logLevel |
Set the log level for network messages (default is Off). |
connections |
All connected players. |
player |
Get the local NetworkPlayer instance. |
isClient |
Returns true if your peer type is client. |
isServer |
Returns true if your peer type is server. |
peerType |
The status of the peer type, i.e. if it is disconnected, connecting, server or client. |
sendRate |
The default send rate of network updates for all Network Views. |
isMessageQueueRunning |
Enable or disable the processing of network messages. |
time |
Get the current network time (seconds). |
minimumAllocatableViewIDs |
Get or set the minimum number of ViewID numbers in the ViewID pool given to clients by the server. |
natFacilitatorIP |
The IP address of the NAT punchthrough facilitator. |
natFacilitatorPort |
The port of the NAT punchthrough facilitator. |
connectionTesterIP |
The IP address of the connection tester used in Network.TestConnection. |
connectionTesterPort |
The port of the connection tester used in Network.TestConnection. |
maxConnections |
Set the maximum amount of connections/players allowed. |
proxyIP |
The IP address of the proxy server. |
proxyPort |
The port of the proxy server. |
useProxy |
Indicate if proxy support is needed, in which case traffic is relayed through the proxy server. |
proxyPassword |
Set the proxy server password. |
InitializeServer |
Initialize the server. |
InitializeSecurity |
Initializes security layer. |
Connect |
Connect to the specified host (ip or domain name) and server port. |
Disconnect |
Close all open connections and shuts down the network interface. |
CloseConnection |
Close the connection to another system. |
AllocateViewID |
Query for the next available network view ID number and allocate it (reserve). |
Instantiate |
Network instantiate a prefab. |
Destroy |
Destroy the object associated with this view ID across the network. |
DestroyPlayerObjects |
Destroy all the objects based on view IDs belonging to this player. |
RemoveRPCs |
Remove all RPC functions which belong to this player ID. |
RemoveRPCsInGroup |
Remove all RPC functions which belong to given group number. |
SetLevelPrefix |
Set the level prefix which will then be prefixed to all network ViewID numbers. |
GetLastPing |
The last ping time to the given player in milliseconds. |
GetAveragePing |
The last average ping time to the given player in milliseconds. |
SetReceivingEnabled |
Enable or disables the reception of messages in a specific group number from a specific player. |
SetSendingEnabled |
Enables or disables transmission of messages and RPC calls on a specific network group number. |
TestConnection |
Test this machines network connection. |
TestConnectionNAT |
Test the connecction specifically for NAT punchthrough connectivity. |
HavePublicAddress |
Check if this machine has a public IP address. |