So, I’m having these two classes:
public class Country : MonoBehaviour
{
// stuff
}
public class Unit : MonoBehaviour
{
Country _country;
//.. other stuff
}
The objects the classes are attached to both contains Networkviews (Delta compressed
obsering Country.cs respectively Unit.cs).
Now I’m writing the OnSerializeNetworkView() function for the unit.
void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
{
if (stream.isWriting)
{
Vector3 pos = transform.position;
stream.Serialize(ref pos);
// write _country here
}
else
{
Vector3 posReceive = Vector3.zero;
stream.Serialize(ref posReceive);
transform.position = posReceive;
// read _country here
}
}
What’s the best way to write/read the _country variable in this case? Is there some id that can be used, or do I have to manually add some unique id to the country and match the units and countries together once they’re all on the client?
/ Thanks