// Update is called once per frame void Update() { if (owner) { if (follow != null) { transform.position = follow.transform.position; transform.rotation = follow.transform.rotation; body.isKinematic = true; } else { body.isKinematic = false; } state.transform.position = transform.localPosition; state.transform.rotation = transform.localRotation; context.Send(ReferenceCountedSceneGraphMessage.Rent(JsonUtility.ToJson(state))); } else { transform.localPosition = state.transform.position; transform.localRotation = state.transform.rotation; body.isKinematic = true; } #pragma warning disable 0618 particles.enableEmission = state.lit; //using deprecated one because its not clear how to update the non-deprecated emissions struct. play/stop dont do the same thing. #pragma warning restore 0618 }
public void Send(string type, object argument) { var msg = ReferenceCountedSceneGraphMessage.Rent(JsonUtility.ToJson(new Message(type, argument))); msg.objectid = peer.NetworkObjectId; msg.componentid = NetworkScene.GetComponentId <RoomClient>(); Send(msg); }
private void Send() { var transformBytes = MemoryMarshal.AsBytes(new ReadOnlySpan <State>(state)); var message = ReferenceCountedSceneGraphMessage.Rent(transformBytes.Length); transformBytes.CopyTo(new Span <byte>(message.bytes, message.start, message.length)); context.Send(message); }
public static ReferenceCountedSceneGraphMessage Rent(string str) { var strBytes = Encoding.UTF8.GetBytes(str); var message = new LogManagerMessage(ReferenceCountedSceneGraphMessage.Rent(strBytes.Length + headerLength)); message.Header[0] = 0x2; new Span <byte>(strBytes).CopyTo(message.Bytes); return(message.buffer); }
public static ReferenceCountedSceneGraphMessage Rent(ReadOnlySpan <byte> bytes, byte tag) { var message = new LogManagerMessage(ReferenceCountedSceneGraphMessage.Rent(bytes.Length + headerLength)); message.Header[0] = 0x1; message.Header[1] = tag; bytes.CopyTo(message.Bytes); return(message.buffer); }
private void Send() { // Co-ords from hints are already in local to our network scene // so we can send them without any changes var transformBytes = MemoryMarshal.AsBytes(new ReadOnlySpan <State>(state)); var message = ReferenceCountedSceneGraphMessage.Rent(transformBytes.Length); transformBytes.CopyTo(new Span <byte>(message.bytes, message.start, message.length)); context.Send(message); }
private void Send() { if (transforms == null || transforms.Length != flock.boids.Length) { transforms = new TransformMessage[flock.boids.Length]; } for (int i = 0; i < flock.boids.Length; i++) { transforms[i].position = flock.boids[i].transform.localPosition; transforms[i].rotation = flock.boids[i].transform.localRotation; } var transformsBytes = MemoryMarshal.AsBytes(new ReadOnlySpan <TransformMessage>(transforms)); var message = ReferenceCountedSceneGraphMessage.Rent(transformsBytes.Length); transformsBytes.CopyTo(new Span <byte>(message.bytes, message.start, message.length)); context.Send(message); }
// Update is called once per frame void Update() { if (run) { for (int i = 0; i < messagesPerFrame; i++) { if (sent >= totalMessages) { return; } int length = UnityEngine.Random.Range(hashLength + 2, maxMessageSize); var message = ReferenceCountedSceneGraphMessage.Rent(length); var datalength = length - hashLength; for (int j = 0; j < datalength; j++) { message.bytes[message.start + j] = (byte)UnityEngine.Random.Range(0, 255); } Array.Copy(sha526.ComputeHash(message.bytes, message.start, datalength), 0, message.bytes, message.start + datalength, hashLength); if (corrupt) { for (int j = 0; j < datalength; j++) { message.bytes[message.start + j] = (byte)UnityEngine.Random.Range(0, 255); } } context.Send(message); sent++; } } }