MonoBehaviour
- Awake
- CancelInvoke
- FixedUpdate
- InvokeRepeating
- Invoke
- IsInvoking
- LateUpdate
- OnApplicationFocus
- OnApplicationPause
- OnApplicationQuit
- OnBecameInvisible
- OnBecameVisible
- OnCollisionEnter
- OnCollisionExit
- OnCollisionStay
- OnConnectedToServer
- OnControllerColliderHit
- OnDestroy
- OnDisable
- OnDisconnectedFromServer
- OnDrawGizmosSelected
- OnDrawGizmos
- OnEnable
- OnFailedToConnectToM...
- OnFailedToConnect
- OnGUI
- OnJointBreak
- OnLevelWasLoaded
- OnMasterServerEvent
- OnMouseDown
- OnMouseDrag
- OnMouseEnter
- OnMouseExit
- OnMouseOver
- OnMouseUpAsButton
- OnMouseUp
- OnNetworkInstantiate
- OnParticleCollision
- OnPlayerConnected
- OnPlayerDisconnected
- OnPostRender
- OnPreCull
- OnPreRender
- OnRenderImage
- OnRenderObject
- OnSerializeNetworkView
- OnServerInitialized
- OnTriggerEnter
- OnTriggerExit
- OnTriggerStay
- OnWillRenderObject
- Reset
- StartCoroutine
- Start
- StopAllCoroutines
- StopCoroutine
- Update
- useGUILayout
MonoBehaviour.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 = 0;
void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info) {
if (stream.isWriting) {
int healthC = currentHealth;
stream.Serialize(ref healthC);
} else {
int healthZ = 0;
stream.Serialize(ref healthZ);
currentHealth = healthZ;
}
}
}
// This objects health information
// 此物体的健康信息
var currentHealth : int = 0;
function OnSerializeNetworkView(stream : BitStream , info : NetworkMessageInfo ) {
if (stream.isWriting) {
var healthC : int = currentHealth;
stream.Serialize(healthC);
} else {
var healthZ : int = 0;
stream.Serialize(healthZ);
currentHealth = healthZ;
}
}
最后修改:2011年1月2日 Sunday 19:00