Reduced memory allocations in NetworkedTransform
This commit is contained in:
parent
27798000ba
commit
7338299ff2
@ -31,6 +31,8 @@ namespace MLAPI.MonoBehaviours.Prototyping
|
|||||||
[Tooltip("If enable proximity is turned on, on clients within this range will be recieving position updates from the server")]
|
[Tooltip("If enable proximity is turned on, on clients within this range will be recieving position updates from the server")]
|
||||||
public float ProximityRange = 50;
|
public float ProximityRange = 50;
|
||||||
|
|
||||||
|
private static byte[] positionUpdateBuffer = new byte[24];
|
||||||
|
|
||||||
private void OnValidate()
|
private void OnValidate()
|
||||||
{
|
{
|
||||||
if (!AssumeSyncedSends && InterpolatePosition)
|
if (!AssumeSyncedSends && InterpolatePosition)
|
||||||
@ -69,7 +71,7 @@ namespace MLAPI.MonoBehaviours.Prototyping
|
|||||||
lastSendTime = Time.time;
|
lastSendTime = Time.time;
|
||||||
lastSentPos = transform.position;
|
lastSentPos = transform.position;
|
||||||
lastSentRot = transform.rotation;
|
lastSentRot = transform.rotation;
|
||||||
using (MemoryStream writeStream = new MemoryStream(24))
|
using (MemoryStream writeStream = new MemoryStream(positionUpdateBuffer))
|
||||||
{
|
{
|
||||||
using (BinaryWriter writer = new BinaryWriter(writeStream))
|
using (BinaryWriter writer = new BinaryWriter(writeStream))
|
||||||
{
|
{
|
||||||
@ -151,7 +153,7 @@ namespace MLAPI.MonoBehaviours.Prototyping
|
|||||||
transform.position = new Vector3(xPos, yPos, zPos);
|
transform.position = new Vector3(xPos, yPos, zPos);
|
||||||
transform.rotation = Quaternion.Euler(new Vector3(xRot, yRot, zRot));
|
transform.rotation = Quaternion.Euler(new Vector3(xRot, yRot, zRot));
|
||||||
}
|
}
|
||||||
using (MemoryStream writeStream = new MemoryStream(24))
|
using (MemoryStream writeStream = new MemoryStream(positionUpdateBuffer))
|
||||||
{
|
{
|
||||||
using(BinaryWriter writer = new BinaryWriter(writeStream))
|
using(BinaryWriter writer = new BinaryWriter(writeStream))
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user