Stream Send receive variable via photon cloud in js script

I search everywhere but could never find a working code in js script.

I need to send and receive a variable via photon cloud.

My photonnetwork is already in my Plugin folder…

Thanks for any tips !)

I finaly get it !!! !)

So here’s my way to do this :
a:
1/ import photon cloud

2/ Drag the PhotonNetworks folder and the UtilityScript folder
in the Plugins folder

alt text

3/ erase the Demos folder !
It will make a lot of error even if you don’t use the script inside…
Erase and have a copy or find a folder where it stop to bug … … :slight_smile:

(Another way could be to change the ProjectSetting/scriptcompilationorder to
make the Js script compile after the C# script.)

b:
Now to send and receive the variable your object must be the player you instantiate.
If it’s a common gameobject only the first player would send information.

c:
Probably you have Drag the photonview script in your player game object then drag
your player gameobject (transform) in the photonview script. To communicate move rotation…

Now drag again a photonview script to your player game object !
Now drag the js script component in the new photon view script !

d: here’s the code :

function OnPhotonSerializeView(stream : PhotonStream, info : PhotonMessageInfo )
    { Debug.Log ("photonserial");
     
        if(stream.isWriting){
            stream.SendNext(GameMaster.test);
            Debug.Log("send");
            }
        else{
           
            GameMaster.test = stream.ReceiveNext();
            Debug.Log("receive");
       }

and it works !)