// TODO add nullable support to weaver instead public static void WriteQuaternionNullable(this NetworkWriter writer, Quaternion?value) { writer.WriteBool(value.HasValue); if (value.HasValue) { writer.WriteQuaternion(value.Value); } }
public void Serialize(NetworkWriter writer) { writer.WritePackedUInt32(netId); writer.WriteBoolean(owner); writer.WriteUInt64(sceneId); writer.WriteVector3(position); writer.WriteQuaternion(rotation); writer.WriteVector3(scale); writer.WriteBytesAndSizeSegment(payload); }
public static void SerializeIntoWriter(NetworkWriter writer, Vector3 position, Quaternion rotation, Vector3 scale) { // serialize position, rotation, scale // note: we do NOT compress rotation. // we are CPU constrained, not bandwidth constrained. // the code needs to WORK for the next 5-10 years of development. writer.WriteVector3(position); writer.WriteQuaternion(rotation); writer.WriteVector3(scale); }
public void Serialize(NetworkWriter writer) { writer.WritePackedUInt32(netId); writer.WriteBoolean(isLocalPlayer); writer.WritePackedUInt64(sceneId); if (sceneId == 0) { writer.WriteGuid(assetId); } writer.WriteVector3(position); writer.WriteQuaternion(rotation); writer.WriteVector3(scale); writer.WriteBytesAndSizeSegment(payload); }
// serialization is needed by OnSerialize and by manual sending from authority // public only for tests public static void SerializeIntoWriter(NetworkWriter writer, Vector3 position, Quaternion rotation, Vector3 scale, bool compressRotation) { // serialize position, rotation, scale // => compress rotation from 4*4=16 to 4 bytes // => less bandwidth = better CCU tests / scale writer.WriteVector3(position); if (compressRotation) { // smalles three compression for 3D writer.WriteUInt32(Compression.CompressQuaternion(rotation)); } else { // uncompressed for 2D writer.WriteQuaternion(rotation); } writer.WriteVector3(scale); }
public override bool OnSerialize(NetworkWriter writer, bool initialState) { // sync target component's position on spawn. // fixes https://github.com/vis2k/Mirror/pull/3051/ // (Spawn message wouldn't sync NTChild positions either) if (initialState) { if (syncPosition) { writer.WriteVector3(targetComponent.localPosition); } if (syncRotation) { writer.WriteQuaternion(targetComponent.localRotation); } if (syncScale) { writer.WriteVector3(targetComponent.localScale); } return(true); } return(false); }