converting Photon stream to JS

could someone help me convert this code to javascript?

void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) {
	
	if(stream.isWriting) {
		stream.SendNext(position);
		stream.SendNext(movespeed);
		stream.SendNext(up);
		stream.SendNext(down);
		stream.SendNext(left);
		stream.SendNext(right);
	}
	else {
		position = (Transform)stream.ReceiveNext();
		movespeed = (int)stream.ReceiveNext();
		up = (bool)stream.ReceiveNext();
		down = (bool)stream.ReceiveNext();
		left = (bool)stream.ReceiveNext();
		right = (bool)stream.ReceiveNext();
	}
	
}

i have tryed many different ways and i just cant seem to get it right!

TTHANK YOU,

mewhy

Try boolean instead of bool, that should be it.

// UnityScript
function OnPhotonSerializeView(stream : PhotonStream, info : PhotonMessageInfo)
{
if(stream.isWriting)
{
stream.SendNext(position);
stream.SendNext(movespeed);
stream.SendNext(up);
stream.SendNext(down);
stream.SendNext(left);
stream.SendNext(right);
}
else
{
position = stream.ReceiveNext();
movespeed = stream.ReceiveNext();
up = stream.ReceiveNext();
down = stream.ReceiveNext();
left = stream.ReceiveNext();
right = stream.ReceiveNext();
}
}

Actually i think that the C# code you’ve posted makes no sense. I don’t think you can serialize “Transform” components. Also the variable name is position, so i guess it’s a Vector3.

In UnityScript there is no c-style cast. Usually the compiler will cast automatically, at least the value-types.