How does an implementation of IPunObservable know which value to recieve?
Options
Hey, I'm a new developer working through the tutorial and can´t construct a mental image of how stream.SendNext() and stream.ReceiveNext() works.
My current explanation is that if the stream has writing permission, it sends a serialized data object through the SendNext() method to a List inside the class PhotonStream. However, if the class does not have permission to write it will instead receive a bool from another (I guess converted from the previous) list. How does code ensure that the correct bool is matched with the correct IPunObersvable implementation?
Also bonus question: It says in the description that OnPhotonSerializeView() gets called from PUN, but from where exactly is this? Is PUN a class or how can I observe it to further my understanding of how the call is made?
Best regards!
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { // can only write if photonView.IsMine == true if (stream.IsWriting) { stream.SendNext(isFiring); } else { this.isFiring = (bool)stream.ReceiveNext(); } }
My current explanation is that if the stream has writing permission, it sends a serialized data object through the SendNext() method to a List inside the class PhotonStream. However, if the class does not have permission to write it will instead receive a bool from another (I guess converted from the previous) list. How does code ensure that the correct bool is matched with the correct IPunObersvable implementation?
Also bonus question: It says in the description that OnPhotonSerializeView() gets called from PUN, but from where exactly is this? Is PUN a class or how can I observe it to further my understanding of how the call is made?
Best regards!
0
Comments
-
The sequence is important. You serialize in a specific sequence and have to use the values accordingly.1