简体   繁体   中英

Unity Photon Send data to server

How to possible send data to server and save them there in Unity 5 and Photon? for example send device UID, device Model, Device Name.

You can override OnPhotonSerializeView to write & read data.

void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info){
        if (stream.isWriting) {
            // Write device info
            stream.SendNext (deviceUID);
            stream.SendNext (deviceModel);
            stream.SendNext (deviceName);
        } else {
            // Read device info
            deviceUID = (string)stream.ReceiveNext ();
            deviceModel = (string)stream.ReceiveNext ();
            deviceName = (string)stream.ReceiveNext ();

        }
    }

The order of the variables you send should be in the same order you receive them. Your object also has to have a PhotonView attached to it.

You can see more info here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM