Beispiel #1
0
        public void SerializeIntoWriterTest()
        {
            NetworkWriter writer   = new NetworkWriter();
            Vector3       position = new Vector3(1, 2, 3);
            Quaternion    rotation = new Quaternion(0.1f, 0.2f, 0.3f, 0.4f);
            Vector3       scale    = new Vector3(0.5f, 0.6f, 0.7f);

            NetworkTransformBase.SerializeIntoWriter(writer, position, rotation, scale, true, true);
            NetworkReader reader = new NetworkReader(writer.ToArray());

            Assert.That(reader.ReadVector3(), Is.EqualTo(position));
            Assert.That(reader.ReadUInt(), Is.EqualTo(Compression.CompressQuaternion(rotation)));
            Assert.That(reader.ReadVector3(), Is.EqualTo(scale));
        }
Beispiel #2
0
        public void SerializeIntoWriterTest()
        {
            var writer   = new NetworkWriter();
            var position = new Vector3(1, 2, 3);
            var rotation = new Quaternion(0.1f, 0.2f, 0.3f, 0.4f);
            var scale    = new Vector3(0.5f, 0.6f, 0.7f);

            NetworkTransformBase.SerializeIntoWriter(writer, position, rotation, scale);
            var reader = new NetworkReader(writer.ToArray());

            Assert.That(reader.ReadVector3(), Is.EqualTo(position));
            Assert.That(reader.ReadQuaternion(), Is.EqualTo(rotation));
            Assert.That(reader.ReadVector3(), Is.EqualTo(scale));
        }
Beispiel #3
0
        public void SerializeIntoWriterTest()
        {
            var position = new Vector3(1, 2, 3);
            var rotation = new Quaternion(0.1f, 0.2f, 0.3f, 0.4f).normalized;
            var scale    = new Vector3(0.5f, 0.6f, 0.7f);

            NetworkTransformBase.SerializeIntoWriter(writer, position, rotation, scale);

            reader.Reset(writer.ToArraySegment());

            Assert.That(reader.ReadVector3(), Is.EqualTo(position));
            var actual = reader.ReadQuaternion();

            Assert.That(actual.x, Is.EqualTo(rotation.x).Within(0.01f));
            Assert.That(actual.y, Is.EqualTo(rotation.y).Within(0.01f));
            Assert.That(actual.z, Is.EqualTo(rotation.z).Within(0.01f));
            Assert.That(actual.w, Is.EqualTo(rotation.w).Within(0.01f));
            Assert.That(reader.ReadVector3(), Is.EqualTo(scale));
        }