mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
NetworkTransform.SerializeIntoWriterTest
This commit is contained in:
parent
875f19e030
commit
15c77c6926
@ -16,6 +16,7 @@
|
||||
// * Only way for smooth movement is to use a fixed movement speed during
|
||||
// interpolation. interpolation over time is never that good.
|
||||
//
|
||||
using System.ComponentModel;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Mirror
|
||||
@ -76,7 +77,8 @@ public class DataPoint
|
||||
float lastClientSendTime;
|
||||
|
||||
// serialization is needed by OnSerialize and by manual sending from authority
|
||||
static void SerializeIntoWriter(NetworkWriter writer, Vector3 position, Quaternion rotation, Compression compressRotation, Vector3 scale)
|
||||
[EditorBrowsable(EditorBrowsableState.Never)] // public only for tests
|
||||
public static void SerializeIntoWriter(NetworkWriter writer, Vector3 position, Quaternion rotation, Compression compressRotation, Vector3 scale)
|
||||
{
|
||||
// serialize position
|
||||
writer.WriteVector3(position);
|
||||
|
26
Assets/Mirror/Tests/NetworkTransformTest.cs
Normal file
26
Assets/Mirror/Tests/NetworkTransformTest.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Mirror.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class NetworkTransformTest
|
||||
{
|
||||
[Test]
|
||||
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);
|
||||
|
||||
// Compression.None
|
||||
NetworkTransformBase.SerializeIntoWriter(writer, position, rotation, NetworkTransformBase.Compression.None, scale);
|
||||
NetworkReader reader = new NetworkReader(writer.ToArray());
|
||||
Assert.That(reader.ReadVector3(), Is.EqualTo(position));
|
||||
Assert.That(reader.ReadVector3(), Is.EqualTo(rotation.eulerAngles));
|
||||
Assert.That(reader.ReadVector3(), Is.EqualTo(scale));
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Mirror/Tests/NetworkTransformTest.cs.meta
Normal file
11
Assets/Mirror/Tests/NetworkTransformTest.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3114c5bb742fe41c09ec88e90ac29ef4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user