I would like to have multiple network views on an object. So for the player, I would like for him to have a NetworkView for Reliable Packets and a Network View for Unreliable data such as position.
If I also attach a script to the same object...
and function OnSerializeNetworkView(stream : BitStream, info : NetworkMessageInfo) is called...
How do I know which set of packets I'm sending/recieving?
You can attach two NetworkViews to the same GameObject.
function OnSerializeNetworkView(stream : BitStream, info : NetworkMessageInfo)
Will be called by whichever NetworkView is watching your other script.
- NetworkView A is set to unreliable
and is watching your gameobject
- NetworkView B is set to
reliable and is watching your other
When NetworkView B needs to send it will call OnSerializeNetworkView in your script.
If you want multiple NetworkViews it's probably best to make them in code when you make the gameobject, that way you can keep references to each one. gameObject.networkView could give you either NetworkView so that becomes useless with multiple NetworkViews on one GameObject.
You can't attach two NetworkView components to the same GameObject (or at least it wouldn't make any sense and just cause trouble if it was possible). However, for your use case, you could create a simple hierarchy, e.g. one GameObject with position that is the parent and that has a child which handles your reliable packets.