Serialization of Vector3

So the documentation says:

function Serialize (ref value : Vector3, maxDelta : float = 0.00001F) : void

A guy gave an example:

stream.Serialize( ref transform.position );

but whenever I try to use this i get the following errors:


No appropriate version of 'UnityEngine.BitStream.Serialize' for the argument list '(UnityEngine.Vector3)' was found.

stream.Serialize(transform.position, 0.00001);

No appropriate version of 'UnityEngine.BitStream.Serialize' for the argument list '(UnityEngine.Vector3, float)' was found.

stream.Serialize(ref transform.position);

expecting ), found 'transform'.

stream.Serialize(ref transform.position, 0.00001);

expecting ), found 'transform'.

Someone please tell me what i’m doing wrong :slight_smile:

You can’t pass transform.position to the Serialize function because transorm.position is a property. Try this…

Vector3 position = transform.position;
stream.Serialize(ref position);