protected override void SendDeltaChanges(IEnumerable <INetworkConnection> connections, TransformBroadcasterChangeType changeFlags) { using (StateSynchronizationPerformanceMonitor.Instance.MeasureEventDuration(PerformanceComponentName, "SendDeltaChanges")) using (MemoryStream memoryStream = new MemoryStream()) using (BinaryWriter message = new BinaryWriter(memoryStream)) { TransformBroadcasterService.Instance.WriteHeader(message, this); message.Write(this.Id); message.Write((byte)changeFlags); if (HasFlag(changeFlags, TransformBroadcasterChangeType.Name)) { message.Write(this.CachedName); } if (HasFlag(changeFlags, TransformBroadcasterChangeType.Layer)) { message.Write(previousLayer); } if (HasFlag(changeFlags, TransformBroadcasterChangeType.Parent)) { message.Write(this.ParentId); message.Write(this.transform.GetSiblingIndex()); } if (HasFlag(changeFlags, TransformBroadcasterChangeType.Position)) { message.Write(previousPosition); } if (HasFlag(changeFlags, TransformBroadcasterChangeType.Rotation)) { message.Write(previousRotation); } if (HasFlag(changeFlags, TransformBroadcasterChangeType.Scale)) { message.Write(previousScale); } if (HasFlag(changeFlags, TransformBroadcasterChangeType.IsActive)) { message.Write(this.SynchronizedIsActive); } if (HasFlag(changeFlags, TransformBroadcasterChangeType.RectTransform)) { RectTransform rectTrans = this.gameObject.GetComponent <RectTransform>(); RectTransformBroadcaster.Send(rectTrans, message); } message.Flush(); var data = memoryStream.ToArray(); StateSynchronizationSceneManager.Instance.Send(connections, ref data); } }
protected override void SendDeltaChanges(IEnumerable <SocketEndpoint> endpoints, TransformBroadcasterChangeType changeFlags) { using (MemoryStream memoryStream = new MemoryStream()) using (BinaryWriter message = new BinaryWriter(memoryStream)) { TransformBroadcasterService.Instance.WriteHeader(message, this); message.Write(this.Id); message.Write((byte)changeFlags); if (HasFlag(changeFlags, TransformBroadcasterChangeType.Name)) { message.Write(this.CachedName); } if (HasFlag(changeFlags, TransformBroadcasterChangeType.Layer)) { message.Write(previousLayer); } if (HasFlag(changeFlags, TransformBroadcasterChangeType.Parent)) { message.Write(this.ParentId); message.Write(this.transform.GetSiblingIndex()); } if (HasFlag(changeFlags, TransformBroadcasterChangeType.Position)) { message.Write(previousPosition); } if (HasFlag(changeFlags, TransformBroadcasterChangeType.Rotation)) { message.Write(previousRotation); } if (HasFlag(changeFlags, TransformBroadcasterChangeType.Scale)) { message.Write(previousScale); } if (HasFlag(changeFlags, TransformBroadcasterChangeType.IsActive)) { message.Write(this.SynchronizedIsActive); } if (HasFlag(changeFlags, TransformBroadcasterChangeType.RectTransform)) { RectTransform rectTrans = this.gameObject.GetComponent <RectTransform>(); RectTransformBroadcaster.Send(rectTrans, message); } message.Flush(); StateSynchronizationSceneManager.Instance.Send(endpoints, memoryStream.ToArray()); } }