Network
- AllocateViewID
- CloseConnection
- connections
- connectionTesterIP
- connectionTesterPort
- Connect
- DestroyPlayerObjects
- Destroy
- Disconnect
- GetAveragePing
- GetLastPing
- HavePublicAddress
- incomingPassword
- InitializeSecurity
- InitializeServer
- Instantiate
- isClient
- isMessageQueueRunning
- isServer
- logLevel
- maxConnections
- minimumAllocatableViewIDs
- natFacilitatorIP
- natFacilitatorPort
- OnConnectedToServer
- OnDisconnectedFromServer
- OnFailedToConnectToM...
- OnFailedToConnect
- OnNetworkInstantiate
- OnPlayerConnected
- OnPlayerDisconnected
- OnSerializeNetworkView
- OnServerInitialized
- peerType
- player
- proxyIP
- proxyPassword
- proxyPort
- RemoveRPCsInGroup
- RemoveRPCs
- sendRate
- SetLevelPrefix
- SetReceivingEnabled
- SetSendingEnabled
- TestConnectionNAT
- TestConnection
- time
- useProxy
Network.OnSerializeNetworkView 当序列化网络视图
function OnSerializeNetworkView (stream : BitStream, info : NetworkMessageInfo) : void
Description描述
Used to customize synchronization of variables in a script watched by a network view.
用来在一个由网络视图监控的脚本中自定义变量同步。
It is automatically determined if the variables being serialized should be sent or received, see example below for a better description. This depends on who owns the object, i.e. the owner sends and all others receive.
它自动决定被序列化的变量是否应该发送或接收,看下面一个更好的说明例子。这取决于谁拥有该物体,即所有者发送,其他所有人接收。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public int currentHealth;
void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info) {
int health = 0;
if (stream.isWriting) {
health = currentHealth;
stream.Serialize(ref health);
} else {
stream.Serialize(ref health);
currentHealth = health;
}
}
}
// This objects health information
//这个物体的生命信息
var currentHealth : int;
function OnSerializeNetworkView(stream : BitStream,
info : NetworkMessageInfo) {
var health : int = 0;
if (stream.isWriting) {
health = currentHealth;
stream.Serialize(health);
} else {
stream.Serialize(health);
currentHealth = health;
}
}
最后修改:2011年5月9日 Monday 17:07