Синтаксис:
Используется csharp
void OnSerializeNetworkView (BitStream stream, NetworkMessageInfo info)
{
Vector3 syncPosition = Vector3.zero;
Vector3 syncVelocity = Vector3.zero;
Quaternion syncRotation = Quaternion.identity;
float speed_ = 0;
float strafe_ = 0;
bool walking_ = false;
Debug.Log ("Done 3");
if (stream.isWriting) {
if (mineObject) {
syncPosition = rig.position;
stream.Serialize (ref syncPosition);
syncVelocity = rig.velocity;
stream.Serialize (ref syncVelocity);
syncRotation = rig.rotation;
stream.Serialize (ref syncRotation);
speed_ = speed;
stream.Serialize (ref speed_);
strafe_ = strafe;
stream.Serialize (ref strafe_);
walking_ = walking;
stream.Serialize (ref walking_);
Debug.Log ("Done 2");
}
Debug.Log ("Done 1");
} else {
if (!mineObject) {
stream.Serialize (ref syncPosition);
stream.Serialize (ref syncVelocity);
stream.Serialize (ref syncRotation);
stream.Serialize (ref speed_);
stream.Serialize (ref strafe_);
stream.Serialize (ref walking_);
walking = walking_;
strafe = strafe_;
speed = speed_;
syncTime = 0f;
syncDelay = Time.time - lastSynchronizationTime;
lastSynchronizationTime = Time.time;
syncEndPosition = syncPosition + syncVelocity * syncDelay;
syncStartPosition = rig.position;
syncEndRotation = syncRotation;
syncStartRotation = rig.rotation;
}
}
}
{
Vector3 syncPosition = Vector3.zero;
Vector3 syncVelocity = Vector3.zero;
Quaternion syncRotation = Quaternion.identity;
float speed_ = 0;
float strafe_ = 0;
bool walking_ = false;
Debug.Log ("Done 3");
if (stream.isWriting) {
if (mineObject) {
syncPosition = rig.position;
stream.Serialize (ref syncPosition);
syncVelocity = rig.velocity;
stream.Serialize (ref syncVelocity);
syncRotation = rig.rotation;
stream.Serialize (ref syncRotation);
speed_ = speed;
stream.Serialize (ref speed_);
strafe_ = strafe;
stream.Serialize (ref strafe_);
walking_ = walking;
stream.Serialize (ref walking_);
Debug.Log ("Done 2");
}
Debug.Log ("Done 1");
} else {
if (!mineObject) {
stream.Serialize (ref syncPosition);
stream.Serialize (ref syncVelocity);
stream.Serialize (ref syncRotation);
stream.Serialize (ref speed_);
stream.Serialize (ref strafe_);
stream.Serialize (ref walking_);
walking = walking_;
strafe = strafe_;
speed = speed_;
syncTime = 0f;
syncDelay = Time.time - lastSynchronizationTime;
lastSynchronizationTime = Time.time;
syncEndPosition = syncPosition + syncVelocity * syncDelay;
syncStartPosition = rig.position;
syncEndRotation = syncRotation;
syncStartRotation = rig.rotation;
}
}
}
Не совсем еще разобрался как работает OnSerializeNetworkView. Дело в том, что клиент не проходит дальше stream.isWriting, что я вижу по логам. В чем может быть проблема? У сервера все хорошо, он отправляет данные и получает, а клиент только получает.